Skip to content

Commit

Permalink
Store status code separately
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinwyszynski committed Feb 3, 2023
1 parent d3a0cfc commit ba10baa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func (e *ResponseError) Unwrap() error { return e.Err }
// ServerError indicates that the server returned a response but it was not what
// we consider a successful one.
type ServerError struct {
Body []byte
Status string
Body []byte
Status string
StatusCode int
}

func (e *ServerError) Error() string {
Expand Down
5 changes: 3 additions & 2 deletions graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ func (c *Client) do(ctx context.Context, op operationType, v interface{}, variab

if resp.StatusCode != http.StatusOK {
return &ServerError{
Body: body,
Status: resp.Status,
Body: body,
Status: resp.Status,
StatusCode: resp.StatusCode,
}
}

Expand Down

0 comments on commit ba10baa

Please sign in to comment.