- fix show jd store info when access error
This commit is contained in:
@@ -196,23 +196,28 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
|
|||||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
return retVal, a.rebuildError(err, jdParams)
|
||||||
if codeErr, ok := err.(*utils.ErrorWithCode); ok {
|
}
|
||||||
|
|
||||||
|
func (a *API) rebuildError(inErr error, jdParams map[string]interface{}) (outErr error) {
|
||||||
|
if inErr != nil {
|
||||||
|
if codeErr, ok := inErr.(*utils.ErrorWithCode); ok {
|
||||||
appendErrList := []string{}
|
appendErrList := []string{}
|
||||||
for _, key := range []string{
|
for _, key := range []string{
|
||||||
KeyOutStationNo,
|
KeyOutStationNo,
|
||||||
KeyStationNo,
|
KeyStationNo,
|
||||||
|
"StoreNo",
|
||||||
} {
|
} {
|
||||||
if jdParams[key] != nil {
|
if jdParams[key] != nil {
|
||||||
appendErrList = append(appendErrList, fmt.Sprintf("[%s:%v]", key, jdParams[key]))
|
appendErrList = append(appendErrList, fmt.Sprintf("[%s:%v]", key, jdParams[key]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(appendErrList) > 0 {
|
if len(appendErrList) > 0 {
|
||||||
err = utils.NewErrorCode(strings.Join(appendErrList, ",")+", "+codeErr.ErrMsg(), codeErr.Code())
|
inErr = utils.NewErrorCode(strings.Join(appendErrList, ",")+", "+codeErr.ErrMsg(), codeErr.Code())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal, err
|
return inErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data map[string]interface{}) (interface{}, error) {
|
func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data map[string]interface{}) (interface{}, error) {
|
||||||
@@ -260,6 +265,7 @@ func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, ke
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return utils.DictKeysMan(result, keyToRemove, keyToKeep), nil
|
return utils.DictKeysMan(result, keyToRemove, keyToKeep), nil
|
||||||
}
|
}
|
||||||
|
err = a.rebuildError(err, jdParams)
|
||||||
baseapi.SugarLogger.Infof("AccessAPINoPage failed, apiStr:%s, jdParams:%s, data:%s, error:%v", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult, true), err)
|
baseapi.SugarLogger.Infof("AccessAPINoPage failed, apiStr:%s, jdParams:%s, data:%s, error:%v", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult, true), err)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -357,12 +363,12 @@ func (a *API) AccessAPIHavePage(apiStr string, jdParams map[string]interface{},
|
|||||||
if innerCode != "0" {
|
if innerCode != "0" {
|
||||||
err2 := utils.NewErrorCode(getErrMsgFromData(data), innerCode, 1)
|
err2 := utils.NewErrorCode(getErrMsgFromData(data), innerCode, 1)
|
||||||
baseapi.SugarLogger.Infof("AccessAPIHavePage failed, apiStr:%s, jdParams:%s, data:%s, error:%v", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult, true), err2)
|
baseapi.SugarLogger.Infof("AccessAPIHavePage failed, apiStr:%s, jdParams:%s, data:%s, error:%v", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult, true), err2)
|
||||||
return nil, totalCount, err2
|
return nil, totalCount, a.rebuildError(err2, jdParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
inResult, totalCount2, err := pageResultParser(data, totalCount)
|
inResult, totalCount2, err := pageResultParser(data, totalCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, totalCount, err
|
return nil, totalCount, a.rebuildError(err, jdParams)
|
||||||
}
|
}
|
||||||
totalCount = totalCount2
|
totalCount = totalCount2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user