mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 08:18:30 +00:00
tpl/data: Print response body on HTTP errors
Which makes it easier to debug.
This commit is contained in:
1 file changed
+4
-5
@@ -55,18 +55,17 @@ func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (b
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if isHTTPError(res) {
|
||||
return nil, errors.Errorf("Failed to retrieve remote file: %s", http.StatusText(res.StatusCode))
|
||||
}
|
||||
|
||||
var b []byte
|
||||
b, err = ioutil.ReadAll(res.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.Body.Close()
|
||||
|
||||
if isHTTPError(res) {
|
||||
return nil, errors.Errorf("Failed to retrieve remote file: %s, body: %q", http.StatusText(res.StatusCode), b)
|
||||
}
|
||||
|
||||
retry, err = unmarshal(b)
|
||||
|
||||
if err == nil {
|
||||
|
||||
Reference in new issue
Block a user