- output msg when AccessAPI failed for ebai, mtwm and jd.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -111,6 +112,7 @@ func (a *API) AccessAPI(cmd string, body map[string]interface{}) (retVal *Respon
|
||||
if retVal.ErrNo == 0 {
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
}
|
||||
baseapi.SugarLogger.Debugf("ebai AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
newErr := utils.NewErrorIntCode(retVal.Error, retVal.ErrNo)
|
||||
// todo 包括访问超频的很多错误都是这个错误号...
|
||||
// if newErr.IntCode() == 20212 {
|
||||
|
||||
@@ -190,6 +190,7 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
|
||||
} else if _, ok := canRetryCodes[code]; ok {
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
} else {
|
||||
baseapi.SugarLogger.Debugf("jd AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
}
|
||||
})
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -58,7 +59,7 @@ func (a *API) genURL(cmd string) string {
|
||||
return apiURL + "/" + cmd
|
||||
}
|
||||
|
||||
func (a *API) signParams(cmd string, params map[string]interface{}) string {
|
||||
func (a *API) signParams(signURL string, params map[string]interface{}) string {
|
||||
keys := make([]string, 0)
|
||||
for k := range params {
|
||||
if k != signKey {
|
||||
@@ -67,7 +68,7 @@ func (a *API) signParams(cmd string, params map[string]interface{}) string {
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
finalStr := a.genURL(cmd) + "?"
|
||||
finalStr := signURL
|
||||
kvPaires := make([]string, len(keys))
|
||||
for k, key := range keys {
|
||||
if params[key] != nil {
|
||||
@@ -88,7 +89,8 @@ func (a *API) AccessAPI(cmd string, isGet bool, bizParams map[string]interface{}
|
||||
if imgData != nil {
|
||||
delete(params, KeyImgData)
|
||||
}
|
||||
params[signKey] = a.signParams(cmd, params)
|
||||
signURL := a.genURL(cmd) + "?"
|
||||
params[signKey] = a.signParams(signURL, params)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
@@ -132,6 +134,7 @@ func (a *API) AccessAPI(cmd string, isGet bool, bizParams map[string]interface{}
|
||||
return platformapi.ErrLevelGeneralFail, platformapi.ErrResponseDataFormatWrong
|
||||
}
|
||||
if _, ok := jsonResult1["error"]; ok {
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
errorInfo := jsonResult1["error"].(map[string]interface{})
|
||||
newErr := utils.NewErrorIntCode(errorInfo["msg"].(string), int(utils.MustInterface2Int64(errorInfo["code"])))
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
|
||||
Reference in New Issue
Block a user