Skip to content

Check HTTP response status codes in fetch() - #22

Merged
bamnet merged 3 commits into
masterfrom
issue-12-check-http-status
Jun 29, 2026
Merged

Check HTTP response status codes in fetch()#22
bamnet merged 3 commits into
masterfrom
issue-12-check-http-status

Conversation

@bamnet-bot

Copy link
Copy Markdown
Collaborator

Fixes #12, #18

Add APIError type capturing status code and response body for non-2xx
responses. Define ErrUnexpectedStatus sentinel error for callers using
errors.Is. Update fetch() to return APIError when the HTTP status code
is outside the 200-299 range.

Fixes #12, #18

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces structured error handling for non-2xx HTTP responses in the NJTransit API client by defining an APIError struct and ErrUnexpectedStatus error, along with corresponding unit tests. The reviewer suggests falling back to http.StatusText when the error response body is empty to improve error message readability, and truncating the stored error body to prevent high memory usage and log pollution from large upstream error responses.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread client.go
Comment thread client.go
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.01%. Comparing base (250c6e8) to head (4d30d57).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
+ Coverage   84.24%   85.01%   +0.76%     
==========================================
  Files           5        5              
  Lines         273      287      +14     
==========================================
+ Hits          230      244      +14     
  Misses         26       26              
  Partials       17       17              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bamnet
bamnet merged commit 6d352a0 into master Jun 29, 2026
3 checks passed
@bamnet-bot
bamnet-bot deleted the issue-12-check-http-status branch June 29, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check HTTP response status codes in fetch()

2 participants