Properly handle non-200 responses from logs
This commit is contained in:
parent
1fc964732b
commit
196bd864cd
|
@ -106,6 +106,9 @@ func (c *LogClient) fetchAndParse(uri string, res interface{}) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if resp.StatusCode / 100 != 2 {
|
||||||
|
return fmt.Errorf("GET %s: %s (%s)", uri, resp.Status, string(body))
|
||||||
|
}
|
||||||
if err = json.Unmarshal(body, &res); err != nil {
|
if err = json.Unmarshal(body, &res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue