2
The exception that is being thrown does not have the messages
attribute. messages
attribute is only available for Django’s ValidationError
s type exceptions and its subclasses. To handle Stripe’s errors, see this example:
try:
# Use Stripe's library to make requests...
pass
except stripe.error.CardError as e:
# Since it's a decline, stripe.error.CardError will be caught
body = e.json_body
err = body['error']
Source:stackexchange.com