-
Notifications
You must be signed in to change notification settings - Fork 418
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
Add property accessor for error messages #422
Conversation
Hey @seants, thanks a lot for the PR! So I think in the case of Python 3, the preferred method of extracting a message from an error is now just this:
Does that look okay as an alternative to you? |
Oh sorry I forgot to add that to the description: that doesn’t work for me because that prints Request ch_1674827andv: your card was declined And we don’t want to show that first part to the user |
Ah, I see! Thanks for the clarification. @ob-stripe Do you have an opinion on this one? I could see either doing something similar to the suggested above, and I could also see inverting the problem by removing the "Request xxx: " prefix from the standard string representation and adding a |
That would've been nice initially but is a breaking change for all clients that depend on that behavior. I could totally imagine someone doing |
In terms of naming, I was gonna go for |
Hey @seants, sorry about the dropping the ball here! I think I archived this by accident. Okay, thank you for explanation on backwards compatibility — agreed. Would you mind renaming the method to |
Haha no worries; yes I'll take care of those this weekend! |
Updated! |
Thanks! Released as 1.82.0. |
Thanks! |
In python3, it's no longer possible to do
error.message
.The official python alternative of
str(error)
does not work with the stripe library because__str__
is overridden and would printwhich is not user-friendly. The three alternatives I've identified are
none of which are super elegant. This PR would allow
instead. Happy to rename it to something else too.