mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-28 17:51:04 +00:00
Don't double log errors in Request()
This commit is contained in:
parent
e602f0f3ce
commit
158c7f9231
10
utils.go
10
utils.go
@ -69,8 +69,7 @@ func RenderString(s string, ctx interface{}) (string, error) {
|
||||
func Request(method, uri string, headers http.Header, body io.Reader) (*http.Response, error) {
|
||||
req, err := http.NewRequest(method, uri, body)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("%s: http.NewRequest fail: %s", uri, err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("%s: http.NewRequest fail: %s", uri, err)
|
||||
}
|
||||
|
||||
if headers == nil {
|
||||
@ -90,14 +89,11 @@ func Request(method, uri string, headers http.Header, body io.Reader) (*http.Res
|
||||
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("%s: client.Do fail: %s", uri, err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("%s: client.Do fail: %s", uri, err)
|
||||
}
|
||||
|
||||
if res.StatusCode/100 != 2 {
|
||||
err = fmt.Errorf("non-2xx response received: %s", res.Status)
|
||||
log.Errorf("%s: request returned an error: %s", uri, err)
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("non-2xx response received: %s", res.Status)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
Loading…
Reference in New Issue
Block a user