From: Bjørn Erik Pedersen Date: Mon, 7 Jun 2021 10:06:27 +0000 (+0200) Subject: tpl/data: Print response body on HTTP errors X-Git-Tag: v0.84.0~27 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=282f1aa3db9f6420fdd360e46db1ffadd5b083a1;p=brevno-suite%2Fhugo tpl/data: Print response body on HTTP errors Which makes it easier to debug. --- diff --git a/tpl/data/resources.go b/tpl/data/resources.go index 68f18c48..b38b2784 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 {