- change log level to info when err in AccessFreshFood.
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
package freshfood
|
package freshfood
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi"
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||||
@@ -93,6 +93,10 @@ type FreshFoodAPI struct {
|
|||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrFreshFooddReturnNot200 = errors.New("freshfood return code is not 200")
|
||||||
|
)
|
||||||
|
|
||||||
func NewFreshFoodAPI(baseURL string) *FreshFoodAPI {
|
func NewFreshFoodAPI(baseURL string) *FreshFoodAPI {
|
||||||
return &FreshFoodAPI{baseURL, &http.Client{Timeout: time.Second * 5}}
|
return &FreshFoodAPI{baseURL, &http.Client{Timeout: time.Second * 5}}
|
||||||
}
|
}
|
||||||
@@ -114,7 +118,7 @@ func (f *FreshFoodAPI) AccessFreshFood(apiStr string, params url.Values) error {
|
|||||||
if err == nil && response != nil && response.StatusCode == 200 {
|
if err == nil && response != nil && response.StatusCode == 200 {
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Warnf("Call %s error:%v, response: %v", fullURL, err, response)
|
globals.SugarLogger.Infof("Call %s error:%v, response: %v", fullURL, err, response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil || response.StatusCode != 200 {
|
if err != nil || response.StatusCode != 200 {
|
||||||
@@ -122,7 +126,7 @@ func (f *FreshFoodAPI) AccessFreshFood(apiStr string, params url.Values) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return platformapi.ErrHTTPCodeIsNot200
|
return ErrFreshFooddReturnNot200
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user