diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-21 12:20:21 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-22 20:46:14 +0200 |
commit | d1661b823af25c50d3bbe5366ea40a3cdd52e237 (patch) | |
tree | cd84d18229fb9c294ff1be56d7c0ce92a8f46761 /tpl/data/data.go | |
parent | 7930d2132a3c36c1aaca20f16f56978c84656b0a (diff) |
hugolib: Continue the file context/line number errors work
See #5324
Diffstat (limited to 'tpl/data/data.go')
-rw-r--r-- | tpl/data/data.go | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/tpl/data/data.go b/tpl/data/data.go index 3f87eda31..03fd27606 100644 --- a/tpl/data/data.go +++ b/tpl/data/data.go @@ -59,7 +59,7 @@ func (ns *Namespace) GetCSV(sep string, urlParts ...string) (d [][]string, err e var req *http.Request req, err = http.NewRequest("GET", url, nil) if err != nil { - return nil, _errors.Wrapf(err, "Failed to create request for getCSV for resource %s:", url) + return nil, _errors.Wrapf(err, "failed to create request for getCSV for resource %s", url) } req.Header.Add("Accept", "text/csv") @@ -68,28 +68,22 @@ func (ns *Namespace) GetCSV(sep string, urlParts ...string) (d [][]string, err e var c []byte c, err = ns.getResource(req) if err != nil { - ns.deps.Log.ERROR.Printf("Failed to read CSV resource %q: %s", url, err) - return nil, nil + return nil, _errors.Wrapf(err, "failed to read CSV resource %q", url) } if !bytes.Contains(c, []byte(sep)) { - ns.deps.Log.ERROR.Printf("Cannot find separator %s in CSV for %s", sep, url) - return nil, nil + return nil, _errors.Errorf("cannot find separator %s in CSV for %s", sep, url) } if d, err = parseCSV(c, sep); err != nil { - ns.deps.Log.WARN.Printf("Failed to parse CSV file %s: %s", url, err) + err = _errors.Wrapf(err, "failed to parse CSV file %s", url) + clearCacheSleep(i, url) continue } break } - if err != nil { - ns.deps.Log.ERROR.Printf("Failed to read CSV resource %q: %s", url, err) - return nil, nil - } - return } @@ -103,7 +97,7 @@ func (ns *Namespace) GetJSON(urlParts ...string) (v interface{}, err error) { var req *http.Request req, err = http.NewRequest("GET", url, nil) if err != nil { - return nil, _errors.Wrapf(err, "Failed to create request for getJSON resource %s:", url) + return nil, _errors.Wrapf(err, "Failed to create request for getJSON resource %s", url) } req.Header.Add("Accept", "application/json") @@ -111,10 +105,8 @@ func (ns *Namespace) GetJSON(urlParts ...string) (v interface{}, err error) { var c []byte c, err = ns.getResource(req) if err != nil { - ns.deps.Log.ERROR.Printf("Failed to get JSON resource %s: %s", url, err) - return nil, nil + return nil, _errors.Wrapf(err, "failed to get getJSON resource %q", url) } - err = json.Unmarshal(c, &v) if err != nil { ns.deps.Log.WARN.Printf("Cannot read JSON from resource %s: %s", url, err) @@ -127,7 +119,7 @@ func (ns *Namespace) GetJSON(urlParts ...string) (v interface{}, err error) { } if err != nil { - ns.deps.Log.ERROR.Printf("Failed to get JSON resource %s: %s", url, err) + return nil, _errors.Wrapf(err, "failed to get getJSON resource %q", url) return nil, nil } return |