-
Notifications
You must be signed in to change notification settings - Fork 432
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 repr methods for errors #365
Conversation
Nice. This seems like an improvement. One question: can you explain the precise reasoning in adding |
Ok, we might go with only |
By my reading, if Is there a good reason to change this though? I would have thought that REPLs and the like would use |
Yes, we could also improve |
My intuition is that there isn't enough of a distinction here to merit the two separate implementations — Let's pick either one or the other, add a little bit of testing, and we can get this in. |
Cool. I'll try |
Sounds good. It may also be worth taking a peek at #364 which could come in soon, and which will aim to make stripe-python agnostic to Python 2 versus 3 by using |
Do we want to keep the existing stripe-python/tests/test_error.py Lines 19 to 33 in c3513fb
btw: those tests look like they are expecting pytest (bare assert ), but tests are only run with unittest, right? (and therefore assertEquals should be used?!)
|
Somebody might inspect them for "empty message" and/or 'Request \d+:' etc. |
For B/C I think |
tests/test_error.py
Outdated
else: | ||
self.assertEquals(repr(err), ( | ||
"CardError(message=u'\\xf6re', param='cparam', code='ccode', " | ||
"http_status=403, request_id='123')")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this good for py2?
Rebased. Came back to this since a better repr helps a lot with locals in tracebacks, so please review/answer my previous comments/questions. |
Hey @blueyed, thanks a lot for the contribution. So I think there are two options here:
If you're in a hurry to see this merged in, the first option is probably better since I'm not sure when 2.0 will be released (there are still a bunch of updates I want to include, but this is fairly low on my priority list right now). |
Rebased this on master, using |
Thanks @blueyed! Released as 1.82.2. |
I think this is very useful when looking at tracebacks with locals.
I will add tests in case you would like to take it.