Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-07 13:06:27 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-07 13:06:27 +0300
commit282f1aa3db9f6420fdd360e46db1ffadd5b083a1 (patch)
tree51223fc88190fe044096021acf12a20120fcfc1b /tpl
parentfcd63de3a54fadcd30972654d8eb86dc4d889784 (diff)
tpl/data: Print response body on HTTP errors
Which makes it easier to debug.
Diffstat (limited to 'tpl')
-rw-r--r--tpl/data/resources.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/tpl/data/resources.go b/tpl/data/resources.go
index 68f18c48e..b38b2784a 100644
--- a/tpl/data/resources.go
+++ b/tpl/data/resources.go
@@ -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 {