- 按美团外卖技术支持的说法,把SYS_ERROR(700)当成可重试错误
This commit is contained in:
@@ -40,6 +40,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
ErrCodeSysErr = 700 // 系统错误,按美团外卖技术支持的说法,可当成需重试的错误
|
||||
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
||||
ErrCodeNoAppFood = 805 // 不存在此菜品
|
||||
)
|
||||
@@ -52,6 +53,13 @@ type API struct {
|
||||
config *platformapi.APIConfig
|
||||
}
|
||||
|
||||
var (
|
||||
canRetryCodes = map[int]int{
|
||||
ErrCodeSysErr: 1,
|
||||
ErrCodeAccessLimited: 1,
|
||||
}
|
||||
)
|
||||
|
||||
func New(appID, secret, callbackURL string, config ...*platformapi.APIConfig) *API {
|
||||
curConfig := platformapi.DefAPIConfig
|
||||
if len(config) > 0 {
|
||||
@@ -143,7 +151,7 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
errorInfo := errObj.(map[string]interface{})
|
||||
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), int(utils.MustInterface2Int64(errorInfo["code"])))
|
||||
if newErr.IntCode() == ErrCodeAccessLimited {
|
||||
if canRetryCodes[newErr.IntCode()] == 1 {
|
||||
return platformapi.ErrLevelExceedLimit, newErr
|
||||
}
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
|
||||
Reference in New Issue
Block a user