Skip to content

Commit

Permalink
Check response code for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sriniketh923 committed Jul 8, 2024
1 parent 0502564 commit 39255fd
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 39255fd

Please sign in to comment.