Skip to content

Conversation

@mbroshi-stripe
Copy link
Contributor

@mbroshi-stripe mbroshi-stripe commented Dec 18, 2025

Why?

We did an audit of V2 error-handling across our SDKs, and realized that in V2 APIs, Java users do not get typed exceptions based on HTTP Status Code like they do when calling a V1 API. E.g. a 429 response code from Stripe in V1 throws a RateLimitException, but against a V2 API, it will throw a more generic ApiException. Also, as part of our audit, we decided that it makes more sense to make RateLimitException extend StripeException rather than ApiException (since it does not come explicitly from the Stripe API). The reason it extends ApiException is that we anticipated that it would be in the API (it was briefly in Private Preview), which was a change we made in #2046.

What?

  • Refactors V1 and V2 code paths so they delegate to the same HTTP Status Code based logic
  • RateLimitException now extends StripeException rather than ApiException
  • Tests for all the edge cases of the new behavior

Changelog

  • ⚠️ RateLimitException now extends StripeException rather than ApiException
  • ⚠️ Non-200 status codes from V2 endpoints will throw a StripeException (e.g. RateLimitException, InvalidRequestException, etc.) like in V1 instead of a generic ApiException

@mbroshi-stripe mbroshi-stripe requested a review from a team as a code owner December 18, 2025 21:47
@mbroshi-stripe mbroshi-stripe requested review from prathmesh-stripe and removed request for a team December 18, 2025 21:47
@mbroshi-stripe mbroshi-stripe changed the title Use HTTP status code in V2 errors ⚠️ Use HTTP status code in V2 errors Dec 18, 2025
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.

3 participants