- place detail error msg in ErrorWithCode when access jd api.

This commit is contained in:
gazebo
2018-07-22 13:49:49 +08:00
parent b4090f2c41
commit 0bab97ed2a
5 changed files with 4 additions and 12 deletions

View File

@@ -135,7 +135,6 @@ func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *R
} }
return platformapi.ErrLevelCodeIsNotOK, newErr return platformapi.ErrLevelCodeIsNotOK, newErr
}) })
return retVal, err return retVal, err
} }

View File

@@ -178,7 +178,6 @@ func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *R
return platformapi.ErrLevelCodeIsNotOK, newErr return platformapi.ErrLevelCodeIsNotOK, newErr
} }
}) })
return retVal, err return retVal, err
} }

View File

@@ -60,8 +60,6 @@ type API struct {
} }
var ( var (
InnerCodeIsNotOk = "JD result inner code is not ok"
exceedLimitCodes = map[string]int{ exceedLimitCodes = map[string]int{
ResponseCodeExceedLimit: 1, ResponseCodeExceedLimit: 1,
} }
@@ -167,7 +165,6 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
return platformapi.ErrLevelCodeIsNotOK, newErr return platformapi.ErrLevelCodeIsNotOK, newErr
} }
}) })
return retVal, err return retVal, err
} }
@@ -199,8 +196,7 @@ func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, ke
baseapi.SugarLogger.Errorf("can not find inner data, data:%v", jsonResult) baseapi.SugarLogger.Errorf("can not find inner data, data:%v", jsonResult)
return nil, platformapi.ErrResponseDataFormatWrong return nil, platformapi.ErrResponseDataFormatWrong
} else { } else {
// todo 可以把具体错误消息放进来 return nil, utils.NewErrorCode(string(utils.MustMarshal(data)), innerCode, 1)
return nil, utils.NewErrorCode(InnerCodeIsNotOk, innerCode, 1)
} }
} }
@@ -295,8 +291,7 @@ func (a *API) AccessAPIHavePage(apiStr string, jdParams map[string]interface{},
innerCode := forceInnerCode2Str(data["code"]) innerCode := forceInnerCode2Str(data["code"])
if innerCode != "0" && innerCode != "200" { if innerCode != "0" && innerCode != "200" {
// todo 可以把具体错误消息放进来 return nil, utils.NewErrorCode(string(utils.MustMarshal(data)), innerCode, 1)
return nil, utils.NewErrorCode(InnerCodeIsNotOk, innerCode, 1)
} }
inResult, totalCount2, err := pageResultParser(data, totalCount) inResult, totalCount2, err := pageResultParser(data, totalCount)

View File

@@ -217,7 +217,6 @@ func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *R
newErr := utils.NewErrorIntCode(retVal.Message, code) newErr := utils.NewErrorIntCode(retVal.Message, code)
return platformapi.ErrLevelCodeIsNotOK, newErr return platformapi.ErrLevelCodeIsNotOK, newErr
}) })
return retVal, err return retVal, err
} }

View File

@@ -105,10 +105,10 @@ func MergeMaps(firstMap map[string]interface{}, otherMaps ...map[string]interfac
return retVal return retVal
} }
func CallFuncLogError(funcToCall func() error, msg string) error { func CallFuncLogError(funcToCall func() error, msg string, params ...interface{}) error {
err := funcToCall() err := funcToCall()
if err != nil { if err != nil {
baseapi.SugarLogger.Warnf("%s, error:%v", msg, err.Error()) baseapi.SugarLogger.Warnf("Failed "+msg+" error:%v", append(params, err.Error())...)
} }
return err return err
} }