I've been using Stripe for over a year now, based on Ryan Bates's RailsCast episode found here. However, my error handling has recently stopped working, and I've never seen this error before. I recently began running my app on Ruby 2.1, and as near as I can tell, that's the problem.
This is an instance method in my Subscription
model:
begin
save_with_stripe_payment
rescue Stripe::InvalidRequestError => e
logger.error "Stripe error while creating customer: #{e.message}"
logger.error e.backtrace.join("\n")
errors.add :base, "There was a problem with your card."
false
rescue e
logger.error e.message
logger.error e.backtrace.join("\n")
errors.add :base, e.message
false
end
The line:
rescue Stripe::InvalidRequestError => e
is the one throwing the error. The stacktrace from there goes to the "begin" line, and that's it. What am I missing here?
The line number in the error is a little misleading, the error is actually coming from this:
rescue e
I think you meant
rescue => e
I got this error because I was trying to rescue an array of exceptions, e.g.
rescue *exceptions => e
except that exceptions
was an instance of an exception (my mistake).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With