Merged
Conversation
jar-stripe
approved these changes
Mar 19, 2026
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.
Why?
Earlier this year, we noticed that the Node SDK's error handling algorithm was less precise than the other SDKs. Notably, it didn't let users handle OAuth-related errors as precisely as they should be able to.
There are some breaking changes as part of this work. Mainly, there are more error classes than before, so existing error-handling code may need to change. See the migration guide below for more info.
What?
StripeOAuthError) and associated child classes (StripeInvalidClientError, etc)Stripe.errors.StripeUnknownErrorin favor ofStripeAPIErrorrawTypeunion to include all the new typesSee Also
Changleog
Migration Guide
The SDK's error classes have moved around a bit, so your error handling code may need adjustments. This is especially relevant if you're checking if errors are
instanceofspecificStripe.errors.ABCclasses.StripeUnknownErrorremovedStripeUnknownErrorwas always redundant withStripeAPIError, so we've consolidated around the latter. It continues to represent errors from the Stripe API that don't have more specific types present. You're unlikely to encounter this error type (especially if your API version matches the SDK you're using). If you were usingStripeUnknownErrorto handle OAuth issues, use the new classes (see below).The best way to handle unexpected errors is still to catch
StripeErrordirectly, since all of our Exception classes inherit from that.New OAuth Errors
The Exception class hierarchy has changed slightly. There's a new
StripeOAuthErrorto collect all OAuth-related errorsThis should be compatible with existing code, but it's worth noting that
StripeInvalidGrantErroris no longer a direct child ofStripeError. It's now a grandchild (viaStripeOAuthError).New values in
RawErrorTypeThe
Stripe.RawErrorTypestring literal type has new values to better reflect the errors you may have to handle. (No changes have happened on the API side; the library is just more accurate.)If you have code that performs type narrowing on
Stripe.RawErrorType, you'll likely need to account for the new types.