- 清理三个平台的门店商品批处理操作,部分失败返回失败条目

This commit is contained in:
gazebo
2019-07-21 16:08:37 +08:00
parent 0298f7de71
commit 414c359200
12 changed files with 597 additions and 179 deletions

View File

@@ -7,10 +7,11 @@ import (
)
type ErrorWithCode struct {
level int
errMsg string
code string
intCode int
level int
prefixList []string
errMsg string
code string
intCode int
}
func NewErrorCode(errMsg, code string, level ...int) *ErrorWithCode {
@@ -31,7 +32,11 @@ func NewErrorIntCode(errMsg string, code int, level ...int) *ErrorWithCode {
}
func (e *ErrorWithCode) Error() string {
return fmt.Sprintf("%s level:%d, code:%s", e.errMsg, e.level, e.code)
fullErrMsg := e.ErrMsg()
if len(e.prefixList) > 0 {
fullErrMsg = strings.Join(e.prefixList, ",") + ", " + fullErrMsg
}
return fmt.Sprintf("%s level:%d, code:%s", fullErrMsg, e.Level(), e.Code())
}
func (e *ErrorWithCode) String() string {
@@ -54,6 +59,10 @@ func (e *ErrorWithCode) ErrMsg() string {
return e.errMsg
}
func (e *ErrorWithCode) AddPrefixMsg(prefix string) {
e.prefixList = append(e.prefixList, prefix)
}
func IsErrMatch(err error, strCode string, strList []string) (isMatch bool) {
if err != nil {
if codeErr, ok := err.(*ErrorWithCode); ok {