Skip to content

feat(core): improve public error handling API#1

Merged
AllyMurray merged 5 commits intomainfrom
feat/error-handling-api-improvements
Feb 13, 2026
Merged

feat(core): improve public error handling API#1
AllyMurray merged 5 commits intomainfrom
feat/error-handling-api-improvements

Conversation

@AllyMurray
Copy link
Owner

Summary

  • HttpErrorContext.url: Error handlers now receive the requested URL, enabling logging and error reporting without extra bookkeeping.
  • HttpClientError.data / .headers: The default error path (no errorHandler) now carries the parsed response body and headers on the thrown error, so consumers don't lose context.
  • JSDoc: Documented all HttpErrorContext fields and clarified the responseTransformer vs responseHandler distinction.
  • Type guard: isHttpErrorContext now also checks for the url field.

Test plan

  • pnpm test — all 223 tests pass (includes new assertions for url, data, headers, and type guard branches)
  • pnpm build — clean build with DTS output
  • tsc --noEmit — no type errors
  • docs-site build — all 18 pages build cleanly

🤖 Generated with Claude Code

AllyMurray and others added 5 commits February 13, 2026 15:06
Users who skip errorHandler previously lost the response body and headers
when the default error path threw. Add an optional HttpClientErrorOptions
parameter to the constructor so defaultHttpError can forward them.

The constructor remains backwards-compatible — existing callers that pass
only (message, statusCode) continue to work unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add url field to HttpErrorContext so error handlers can log which
  endpoint failed
- Add JSDoc to all HttpErrorContext fields (data behavior was opaque)
- Update isHttpErrorContext type guard to require url
- Pass data and headers through defaultHttpError to HttpClientError
- Clarify responseTransformer vs responseHandler distinction in JSDoc

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Assert context.url is present and correct in errorHandler test
- Add test: default HttpClientError carries data and headers
- Update generateClientError test to include url and assert data/headers
- Update isServerErrorOrNetworkFailure test objects to include url
- Add branch test for missing url field in type guard

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Show error.data and error.headers in basic error handling example
- Show context.url usage in errorHandler example
- Update options table descriptions for errorHandler, responseTransformer,
  and responseHandler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AllyMurray AllyMurray merged commit cc17261 into main Feb 13, 2026
1 check passed
@AllyMurray AllyMurray deleted the feat/error-handling-api-improvements branch February 13, 2026 15:12
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.

1 participant