Properly handle non-200 responses from logs

This commit is contained in:
Andrew Ayer 2016-06-08 15:18:28 -07:00
parent 1fc964732b
commit 196bd864cd
1 changed files with 3 additions and 0 deletions

View File

@ -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
} }