- 添加SKU,商家分类存在和不存在的错误判断
This commit is contained in:
@@ -3,6 +3,7 @@ package utils
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ErrorWithCode struct {
|
||||
@@ -52,3 +53,19 @@ func (e *ErrorWithCode) IntCode() int {
|
||||
func (e *ErrorWithCode) ErrMsg() string {
|
||||
return e.errMsg
|
||||
}
|
||||
|
||||
func IsErrMatch(err error, strCode string, strList []string) (isMatch bool) {
|
||||
if err != nil {
|
||||
if codeErr, ok := err.(*ErrorWithCode); ok {
|
||||
if strCode == "" || codeErr.Code() == strCode {
|
||||
for _, v := range strList {
|
||||
if strings.Index(codeErr.ErrMsg(), v) > 0 {
|
||||
isMatch = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isMatch
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user