- more error and warn output.
This commit is contained in:
@@ -49,7 +49,7 @@ func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *
|
||||
|
||||
for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} {
|
||||
if request.FormValue(valueKey) == "" {
|
||||
baseapi.SugarLogger.Errorf("Missing mandatory param:%v", valueKey)
|
||||
baseapi.SugarLogger.Errorf("Missing mandatory param PostForm:%v, valueKey:%v", request.PostForm, valueKey)
|
||||
return &CallbackResponse{
|
||||
Code: -1,
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ func AccessPlatformAPIWithRetry(client *http.Client, request *http.Request, conf
|
||||
if ok && err.Timeout() && recoverableErrorRetryCount <= config.MaxRecoverableRetryCount {
|
||||
continue
|
||||
} else {
|
||||
baseapi.SugarLogger.Errorf("access api error:%v", err)
|
||||
baseapi.SugarLogger.Errorf("access api error:%v, request:%v", err, request)
|
||||
return ErrAPIAccessFailed
|
||||
}
|
||||
}
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != 200 {
|
||||
baseapi.SugarLogger.Errorf("HTTP code not 200, it's:%v", response.StatusCode)
|
||||
baseapi.SugarLogger.Errorf("HTTP code not 200, it's:%v, request:%v", response.StatusCode, request)
|
||||
return ErrHTTPCodeIsNot200
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ func HTTPResponse2Json(response *http.Response) (map[string]interface{}, error)
|
||||
var jsonResult map[string]interface{}
|
||||
bodyData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("ioutil.ReadAll error:%v", err)
|
||||
baseapi.SugarLogger.Errorf("ioutil.ReadAll error:%v, response:%v", err, response)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -186,14 +186,14 @@ func HTTPBody2Values(data []byte, needDecode bool) (url.Values, error) {
|
||||
if needDecode {
|
||||
bodyStr1, err := url.QueryUnescape(bodyStr)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("QueryUnescape error:%v", err)
|
||||
baseapi.SugarLogger.Errorf("QueryUnescape error:%v, bodyStr:%v", err, bodyStr)
|
||||
return nil, err
|
||||
}
|
||||
bodyStr = bodyStr1
|
||||
}
|
||||
result, err := url.ParseQuery(bodyStr)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("ParseQuery error:%v", err)
|
||||
baseapi.SugarLogger.Errorf("ParseQuery error:%v, bodyStr:%v", err, bodyStr)
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
@@ -202,7 +202,7 @@ func HTTPBody2Values(data []byte, needDecode bool) (url.Values, error) {
|
||||
func MustInterface2Int64(data interface{}) int64 {
|
||||
dataNumber, ok := data.(json.Number)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("error when convert:%v", data))
|
||||
panic(fmt.Sprintf("error when cast:%v to int64", data))
|
||||
}
|
||||
retVal, err := dataNumber.Int64()
|
||||
if err != nil {
|
||||
@@ -238,7 +238,7 @@ func MergeMaps(firstMap map[string]interface{}, otherMaps ...map[string]interfac
|
||||
func CallFuncLogError(funcToCall func() error, msg string) error {
|
||||
err := funcToCall()
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Warnf("%s, error:%v", err.Error())
|
||||
baseapi.SugarLogger.Warnf("%s, error:%v", msg, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user