fix: map HTTP 402 and 413 to status-specific exceptions - #9
Merged
garretpremo merged 1 commit intoSep 21, 2026
Merged
Conversation
Both fell through to the generic TypeSafeApiException, unlike every other documented status (400/401/403/404/422/429/5xx). Fixes Premo-Cloud#8.
Contributor
|
LGTM! |
gpremo-re
approved these changes
Sep 21, 2026
garretpremo
approved these changes
Sep 21, 2026
garretpremo
left a comment
Contributor
There was a problem hiding this comment.
Reviewed: subclasses match the existing one-liners, switch arms in status order, tests cover both messages, changelog references #8. CI green.
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.
Motivation:
TypeSafeApiException.fromResponsemaps 400/401/403/404/422/429/5xx to status-specific exceptions, but 402 (out of credits) and 413 (payload too large) fell through to the genericTypeSafeApiException, same as an arbitrary unmapped status. Both are documented, actionable API responses. The JS SDK has the identical gap, reported today as typesafe-ai/typesafe-sdk-js#13.Changes:
TypeSafePaymentRequiredExceptionandTypeSafePayloadTooLargeException, one-line subclasses matching the existing style (e.g.TypeSafeBadRequestException)casearms inTypeSafeApiException.fromResponseerrorsMapToStatusSpecificExceptionsWithExtractedMessagescovering the new mappingsNeither status is in
RetryPolicy.DEFAULT_HTTP_STATUSES, so no retry-behavior change.Result:
./gradlew :typesafe-sdk:checkpasses.Fixes: #8