Skip to content

402 and 413 fall through to the generic exception, unlike every other mapped status #8

Description

@Ashfaqbs

Summary

TypeSafeApiException.fromResponse maps 400/401/403/404/422/429/5xx to a status-specific exception, but 402 (Payment Required) and 413 (Payload Too Large) fall through to the generic TypeSafeApiException, same as an unmapped status like 418.

Why these two

Both are documented, actionable API responses (out-of-credits, request-too-large), not arbitrary statuses — same reasoning that gave 400/401/403/404/422/429 their own types. The JS SDK has the identical gap, reported today: typesafe-ai/typesafe-sdk-js#13.

Location

https://github.com/Premo-Cloud/typesafe-sdk-java/blob/main/typesafe-sdk/src/main/java/io/github/premocloud/typesafe/TypeSafeApiException.java#L36-L46

Suggested fix

Add TypeSafePaymentRequiredException and TypeSafePayloadTooLargeException following the existing one-line subclasses (e.g. TypeSafeBadRequestException), and two more case arms in the switch. Neither status is in RetryPolicy.DEFAULT_HTTP_STATUSES, so no retry-behavior change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions