fix cachet api returning bad response code

This commit is contained in:
Matej Kramny
2019-07-27 23:57:06 +07:00
parent 49c009eb30
commit 5f664959db
3 changed files with 84 additions and 0 deletions

View File

@@ -287,6 +287,10 @@ func (api CachetBackend) findIncidents(componentID int, status int) ([]*Incident
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GET /incidents returned %d", resp.StatusCode)
}
var data []*Incident
if err := json.Unmarshal(body.(CachetResponse).Data, &data); err != nil {
return nil, fmt.Errorf("Cannot find incidents: %v", err)