Merge lp://staging/~james-w/lazr.restfulclient/reject-non-json-responses into lp://staging/lazr.restfulclient
Proposed by
James Westby
Status: | Rejected |
---|---|
Rejected by: | Francis J. Lacoste |
Proposed branch: | lp://staging/~james-w/lazr.restfulclient/reject-non-json-responses |
Merge into: | lp://staging/lazr.restfulclient |
Diff against target: |
88 lines (+38/-9) 2 files modified
src/lazr/restfulclient/errors.py (+15/-0) src/lazr/restfulclient/resource.py (+23/-9) |
To merge this branch: | bzr merge lp://staging/~james-w/lazr.restfulclient/reject-non-json-responses |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Francis J. Lacoste (community) | Needs Resubmitting | ||
Graham Binns (community) | code | Approve | |
Review via email: mp+16960@code.staging.launchpad.net |
To post a comment you must log in.
Unmerged revisions
- 87. By James Westby
-
Give a more specific error that will help with debugging.
- 86. By James Westby
-
Use the content-type returned by the response to interpret it.
Using a hardcoded application/json value means that it tries to interpret
any response as JSON, even if it is HTML say. While this doesn't matter for
normal operation with LP it does mean that some errors are masked.
bug shows what happens if you get an unexpected content-type
from the server. This change is an attempt to at least give it
a clearer error message and make it easier to debug.
It firstly uses the content-type returned by the response to
interpret it, rather than hardcoding application/json. It's
conceivable that wadllib knows how to deal with such a content-type,
so it's better to let it find the error.
The second change catches wadllib's error and throws an error
that explains the situation, so you would get something like
https:/ /api.launchpad. net/beta/ ubuntu did not return a usable
content type: This resource doesn't define a representation for
text/html.
with a .content attribute you can print as usual to find out what
you got instead.
I would appreciate some guidance in how to write tests for this
change.
Thanks,
James