Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Stripe error classes #457

Closed
SimonSchick opened this issue May 7, 2018 · 6 comments
Closed

Export Stripe error classes #457

SimonSchick opened this issue May 7, 2018 · 6 comments

Comments

@SimonSchick
Copy link

Would it be possible for all stripe error classes to be exported so we can catch them via instanceof?

brandur-stripe pushed a commit that referenced this issue May 12, 2018
Exports the errors module and the types it contains as `stripe.errors`.
This allows users to match on an error with the `instanceof` operator
instead of having to match on the string generated by accessing an
object's `type`.

Fixes #457.
@brandur-stripe
Copy link
Contributor

That seems reasonable. I've added a pull in #459 and will gather some feedback.

brandur-stripe pushed a commit that referenced this issue May 12, 2018
Exports the errors module and the types it contains as `stripe.errors`.
This allows users to match on an error with the `instanceof` operator
instead of having to match on the string generated by accessing an
object's `type`.

Fixes #457.
@brandur-stripe
Copy link
Contributor

Released as 5.10.0.

@SimonSchick
Copy link
Author

❤️

@SimonSchick
Copy link
Author

Hey sorry to bump this but the way it was implemented is a little annoying to use.
Could you please export the error classes on the root object?

I'm using this library with typescript and it's a little bit annoying to use instanceof with classes that are properties on an instance.

Can you please make it so that require('stripe').errors === require('stripe/lib/errors') pretty please?

@ob-stripe
Copy link
Contributor

Hi @SimonSchick, sorry for the late reply! As of stripe-node 6.18.0, errors are exported on the root Stripe object (in addition to being exported on the client instances).

@SimonSchick
Copy link
Author

Sweet, now I can add those to the DT typings, thanks!

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

No branches or pull requests

3 participants