feat: add errorx.In to facility error checking (#4105)

This commit is contained in:
Kevin Wan
2024-04-27 20:43:45 +08:00
committed by GitHub
parent b337ae36e5
commit bfddb9dae4
7 changed files with 97 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ import (
"errors"
"github.com/zeromicro/go-zero/core/breaker"
"github.com/zeromicro/go-zero/core/errorx"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -267,8 +268,7 @@ func (db *commonSqlConn) TransactCtx(ctx context.Context, fn func(context.Contex
}
func (db *commonSqlConn) acceptable(err error) bool {
if err == nil || errors.Is(err, sql.ErrNoRows) || errors.Is(err, sql.ErrTxDone) ||
errors.Is(err, context.Canceled) {
if err == nil || errorx.In(err, sql.ErrNoRows, sql.ErrTxDone, context.Canceled) {
return true
}