jdapi.AccessAPI2中处理返回结果不是json的情况
This commit is contained in:
@@ -198,12 +198,19 @@ func (a *API) AccessAPI2(apiStr string, jdParams map[string]interface{}, traceIn
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
code := jsonResult1["code"].(string)
|
code := utils.Interface2String(jsonResult1["code"])
|
||||||
|
if code == "" {
|
||||||
|
if jsonResult1[platformapi.KeyData] == nil {
|
||||||
|
baseapi.SugarLogger.Warnf("abnormal jdapi apiStr:%s, jdParams:%s, result:%s", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult1, true))
|
||||||
|
} else {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("%s return not json", apiStr)
|
||||||
|
}
|
||||||
|
}
|
||||||
if code == ResponseCodeSuccess {
|
if code == ResponseCodeSuccess {
|
||||||
retVal = jsonResult1
|
retVal = jsonResult1
|
||||||
return platformapi.ErrLevelSuccess, nil
|
return platformapi.ErrLevelSuccess, nil
|
||||||
}
|
}
|
||||||
newErr := utils.NewErrorCode(jsonResult1["msg"].(string), code)
|
newErr := utils.NewErrorCode(utils.Interface2String(jsonResult1["msg"]), code)
|
||||||
if _, ok := exceedLimitCodes[code]; ok {
|
if _, ok := exceedLimitCodes[code]; ok {
|
||||||
return platformapi.ErrLevelExceedLimit, newErr
|
return platformapi.ErrLevelExceedLimit, newErr
|
||||||
} else if _, ok := canRetryCodes[code]; ok {
|
} else if _, ok := canRetryCodes[code]; ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user