ebaiapi.IsErrSkuExist, IsErrSkuNotExist

This commit is contained in:
gazebo
2020-01-20 09:59:32 +08:00
parent 06c1147292
commit 3c7671b72f
2 changed files with 25 additions and 9 deletions

View File

@@ -71,19 +71,24 @@ func IsErrMatch(err error, strCode string, strList []string) (isMatch bool) {
if err != nil {
if codeErr, ok := err.(*ErrorWithCode); ok {
if strCode == "" || codeErr.Code() == strCode {
isMatch = len(strList) == 0
for _, v := range strList {
if strings.Index(codeErr.ErrMsg(), v) >= 0 {
isMatch = true
break
}
}
isMatch = IsErrMsgMatch(codeErr.ErrMsg(), strList)
}
}
}
return isMatch
}
func IsErrMsgMatch(errMsg string, strList []string) (isMatch bool) {
isMatch = len(strList) == 0
for _, v := range strList {
if strings.Index(errMsg, v) >= 0 {
isMatch = true
break
}
}
return isMatch
}
func GetErrMsg(err error) (errMsg string) {
if errExt, ok := err.(*ErrorWithCode); ok {
errMsg = errExt.ErrMsg()