You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user of the stripe-ruby gem, I expect to be able to handle errors in a generic way.
The current implementation of the error object creates a world where we cannot be sure of when to use code that accesses stripe.error or stripe.message.
Consider the case of exceptions which always have an error object:
require'stripe'defcause_auth_errorStripe::Product.create()rescueStripe::AuthenticationError=>eputse.error.typeputse.messageendcause_auth_error# => test_errors.rb:6:in `rescue in cause_auth_error': undefined method `type' for nil:NilClass (NoMethodError)
It would be nice if the SDK handled wrapping errors and exposing methods in a way that allows for us to generically handle and output all of the possible details.
In the current case, there is a subset of fields available on some errors, so it feels like e.message and a few others are the only safe access we have
The text was updated successfully, but these errors were encountered:
@Wittiest thanks a lot for the detailed report/repro. We'll look into it, I agree we should support the direct access through e.error for all error types
@richardm-stripe it looks like we set the e.error shortcut when de-serializing the raw JSON from the API here. The problem is that in some parts of the library, we might raise an error directly with a raw message which doesn't go through the same steps. The example above is raised here for example.
As a user of the stripe-ruby gem, I expect to be able to handle errors in a generic way.
The current implementation of the error object creates a world where we cannot be sure of when to use code that accesses
stripe.error
orstripe.message
.Consider the case of exceptions which always have an
error
object:The case of exceptions without an error object:
It would be nice if the SDK handled wrapping errors and exposing methods in a way that allows for us to generically handle and output all of the possible details.
In the current case, there is a subset of fields available on some errors, so it feels like
e.message
and a few others are the only safe access we haveThe text was updated successfully, but these errors were encountered: