kulpa / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
Committed, thanks! -joe

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