-
Notifications
You must be signed in to change notification settings - Fork 755
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 errors to allow typed access to them #459
Conversation
(And oops — I meant @jlomas-stripe. Sorry @JLomas!) |
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.
f0c611c
to
a220f18
Compare
@brandur-stripe This looks great. It looks like
...so maybe we should also take this opportunity rename the file to Either way, lgtm |
Yeah, that's basically what stopped me. I think this would still be a good cleanup, but we should also rename the symbol I'll merge this and then see if that tweak works the way we hope on a different PR. Thanks for taking a look! |
Alright, I tried to follow this up with a rename, but it turned into quite a deep rabbit hole that I wasn't prepared for. it('Populates with type and message params', function() {
var e = new Error('FooError', 'Foo happened');
expect(e).to.have.property('type', 'FooError'); It also has the additional problem that the author conflated a class with a package, and throughout much of the file, the singular I'm just going to leave it for now. |
Little bit late here but, why are the errors exported on the client rather than directly from the package, this seems a little counter intuitive since errors are not bound to a stripe instance. |
@SimonSchick What do you mean? What would you expect to be able to do here? Like, |
Exports the errors module and the types it contains as
stripe.errors
.This allows users to match on an error with the
instanceof
operatorinstead of having to match on the string generated by accessing an
object's
type
.There's a bit of an unfortunate singular/plural mismatch (the file is called
Error.js
), but I called the exportstripe.errors
to match thealready-plural
stripe.webhooks
.Fixes #457.
r? @jlomas-stripe Hey! Could I get your opinion on this?
cc @stripe/api-libraries