Error on HTTP resources are not nescessarly protocol related

Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
This commit is contained in:
Sylvain Rabot
2021-12-10 09:27:37 +01:00
parent e65e571ed1
commit 738573b079
3 changed files with 9 additions and 2 deletions

View File

@@ -314,7 +314,7 @@ func (fl *fileLoader) Load(path string) ([]byte, error) {
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, fmt.Errorf("URL returned error %d (%s)", resp.StatusCode, http.StatusText(resp.StatusCode))
return nil, fmt.Errorf("%w: status code %d (%s)", ErrorHTTP, resp.StatusCode, http.StatusText(resp.StatusCode))
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {