mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
tpl/data: Print response body on HTTP errors
Which makes it easier to debug.
This commit is contained in:
parent
fcd63de3a5
commit
282f1aa3db
1 changed files with 4 additions and 5 deletions
|
@ -55,18 +55,17 @@ func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (b
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if isHTTPError(res) {
|
|
||||||
return nil, errors.Errorf("Failed to retrieve remote file: %s", http.StatusText(res.StatusCode))
|
|
||||||
}
|
|
||||||
|
|
||||||
var b []byte
|
var b []byte
|
||||||
b, err = ioutil.ReadAll(res.Body)
|
b, err = ioutil.ReadAll(res.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
res.Body.Close()
|
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)
|
retry, err = unmarshal(b)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Loading…
Reference in a new issue