Skip to content

Commit

Permalink
Check response code for errors (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
sriniketh923 authored Jul 9, 2024
1 parent 0502564 commit cbbf4ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions incident.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ func (c *Client) GetIncidents(ctx context.Context, includeResolved bool, limit i
if resp != nil {
defer resp.Body.Close()
}
if resp.StatusCode != http.StatusOK {
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return nil, fmt.Errorf(string(body))
}
if err != nil {
return nil, err
}
Expand Down

0 comments on commit cbbf4ec

Please sign in to comment.