Skip to content

Commit

Permalink
feat(client): return response with error for non-200 status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxron committed Oct 3, 2024
1 parent 90d06f7 commit c84a22d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c *Client) performRequest(ctx context.Context, httpClient *http.Client, re

// Check for non-ok status codes
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %w: %d", errors.ErrBadStatus, resp.StatusCode)
return resp, fmt.Errorf("unexpected status code: %w: %d", errors.ErrBadStatus, resp.StatusCode)
}

// Log the response details
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (rb *Request) Do(ctx context.Context) (*http.Response, error) {
// Execute the request
resp, err := rb.client.Do(ctx, req)
if err != nil {
return nil, err
return resp, err
}

// If a result is set, unmarshal the response
Expand Down

0 comments on commit c84a22d

Please sign in to comment.