- refactor RebuildError

- output store and sku info when mtwm api failed
This commit is contained in:
gazebo
2019-03-17 21:41:45 +08:00
parent 1cec54c840
commit 26f1d37caf
4 changed files with 38 additions and 43 deletions

View File

@@ -128,23 +128,11 @@ 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 {
appendErrList := []string{}
for _, key := range []string{
KeyBaiduShopID,
KeyShopID,
KeySkuID,
KeyCustomSkuID,
} {
if body[key] != nil {
appendErrList = append(appendErrList, fmt.Sprintf("[%s:%v]", key, body[key]))
}
}
if len(appendErrList) > 0 {
err = utils.NewErrorCode(strings.Join(appendErrList, ",")+", "+codeErr.ErrMsg(), codeErr.Code())
}
}
}
err = platformapi.RebuildError(err, body, []string{
KeyBaiduShopID,
KeyShopID,
KeySkuID,
KeyCustomSkuID,
})
return retVal, err
}