jdapi.AccessAPI2中处理返回结果不是json的情况

This commit is contained in:
gazebo
2019-10-29 15:51:07 +08:00
parent 45c280d8d6
commit 1893c6b37d

View File

@@ -198,12 +198,19 @@ func (a *API) AccessAPI2(apiStr string, jdParams map[string]interface{}, traceIn
if jsonResult1 == 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 {
retVal = jsonResult1
return platformapi.ErrLevelSuccess, nil
}
newErr := utils.NewErrorCode(jsonResult1["msg"].(string), code)
newErr := utils.NewErrorCode(utils.Interface2String(jsonResult1["msg"]), code)
if _, ok := exceedLimitCodes[code]; ok {
return platformapi.ErrLevelExceedLimit, newErr
} else if _, ok := canRetryCodes[code]; ok {