feat(core): improve public error handling API#1
Merged
AllyMurray merged 5 commits intomainfrom Feb 13, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (noerrorHandler) now carries the parsed response body and headers on the thrown error, so consumers don't lose context.HttpErrorContextfields and clarified theresponseTransformervsresponseHandlerdistinction.isHttpErrorContextnow also checks for theurlfield.Test plan
pnpm test— all 223 tests pass (includes new assertions forurl,data,headers, and type guard branches)pnpm build— clean build with DTS outputtsc --noEmit— no type errorsdocs-site build— all 18 pages build cleanly🤖 Generated with Claude Code