diff --git a/platformapi/ebaiapi/ebaiapi.go b/platformapi/ebaiapi/ebaiapi.go index 84c3bb0f..0b409cc5 100644 --- a/platformapi/ebaiapi/ebaiapi.go +++ b/platformapi/ebaiapi/ebaiapi.go @@ -127,5 +127,21 @@ func (a *API) AccessAPI(cmd string, body map[string]interface{}) (retVal *Respon } return platformapi.ErrLevelCodeIsNotOK, newErr }) + if err != nil { + if codeErr, ok := err.(*utils.ErrorWithCode); ok { + if body[KeyBaiduShopID] != nil || body[KeyShopID] != nil { + shopInfoList := []string{} + for _, key := range []string{ + KeyBaiduShopID, + KeyShopID, + } { + if body[key] != nil { + shopInfoList = append(shopInfoList, fmt.Sprintf("[%s:%v]", key, body[key])) + } + } + err = utils.NewErrorCode(strings.Join(shopInfoList, ",")+", "+codeErr.ErrMsg(), codeErr.Code()) + } + } + } return retVal, err } diff --git a/utils/errorwithcode.go b/utils/errorwithcode.go index 25550876..eb474d64 100644 --- a/utils/errorwithcode.go +++ b/utils/errorwithcode.go @@ -7,15 +7,15 @@ import ( type ErrorWithCode struct { level int - str string + errMsg string code string intCode int } -func NewErrorCode(err, code string, level ...int) *ErrorWithCode { +func NewErrorCode(errMsg, code string, level ...int) *ErrorWithCode { retVal := &ErrorWithCode{ - str: err, - code: code, + errMsg: errMsg, + code: code, } retVal.intCode, _ = strconv.Atoi(code) if len(level) > 0 { @@ -25,12 +25,12 @@ func NewErrorCode(err, code string, level ...int) *ErrorWithCode { return retVal } -func NewErrorIntCode(err string, code int, level ...int) *ErrorWithCode { - return NewErrorCode(err, Int2Str(code), level...) +func NewErrorIntCode(errMsg string, code int, level ...int) *ErrorWithCode { + return NewErrorCode(errMsg, Int2Str(code), level...) } func (e *ErrorWithCode) Error() string { - return fmt.Sprintf("%s level:%d, code:%s", e.str, e.level, e.code) + return fmt.Sprintf("%s level:%d, code:%s", e.errMsg, e.level, e.code) } func (e *ErrorWithCode) String() string { @@ -48,3 +48,7 @@ func (e *ErrorWithCode) Code() string { func (e *ErrorWithCode) IntCode() int { return e.intCode } + +func (e *ErrorWithCode) ErrMsg() string { + return e.errMsg +}