- 添加SKU,商家分类存在和不存在的错误判断

This commit is contained in:
gazebo
2019-07-11 21:47:36 +08:00
parent 4a620746c4
commit aa78c0d67f
5 changed files with 73 additions and 21 deletions

View File

@@ -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
}