Skip to content
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

With JSON error payloads, HttpError returns a non-string in __str__ #5

Closed
GoogleCodeExporter opened this issue Mar 20, 2016 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Receiving a JSON error response from a service in JsonModel.response, the 
'detail' attribute passed into HttpError is the result of loading the 'error' 
value in the JSON object, which is also an object/dict and so can't be returned 
from __str__.

I get '<unprintable HttpError>' in tracebacks, which is unhelpful for debugging.

I am not sure what the best way to fix this is, but one possibility is to just 
pass the status and reason into the HttpError in the same way that it is 
handled for non application/json errors. I can prepare a fix/patch to do it 
like this unless someone else has overriding thoughts?

Original issue reported on code.google.com by afs...@google.com on 15 Dec 2010 at 2:56

@GoogleCodeExporter
Copy link
Author

The __str__ response of HttpError is weak, so any improvements you want to 
fix/patch would be very welcome.

Original comment by jcgregorio@google.com on 15 Dec 2010 at 3:24

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

I have written a patch here that might be a good start:

http://code.google.com/r/afshar-json-errorhandling/

1. Moves the display logic out of the model into the error.
2. Add some tests

Original comment by afs...@google.com on 16 Dec 2010 at 9:25

@GoogleCodeExporter
Copy link
Author

Sorry, this is the repository url:

https://afshar-json-errorhandling.googlecode.com/hg/

Original comment by afs...@google.com on 16 Dec 2010 at 9:26

@GoogleCodeExporter
Copy link
Author

Committed, thanks! -joe

Original comment by jcgregorio@google.com on 4 Jan 2011 at 4:03

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant