-
Notifications
You must be signed in to change notification settings - Fork 120
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
slumber.Resource._process_response #112
Comments
Agreed, although it's hard to know what the right thing to do is really. I only see one option, but this is also making some assumptions. Maybe it's the best this API can do: Throw an exception pertaining to the error code range: 4xx, 5xx. With this however, how do we handle the body content, if any, that might provide meaningful information (an assumption unfortunately), e.g. The API might return some helpful information as part of a 410 gone response for example. Maybe we could follow something like algorithm: if not (200 <= resp.status_code <= 299):
body = None
try:
body = self._try_to_serialize_response(resp)
except:
pass
raise HTTPClientError(resp.status_code, body) Thoughts? |
Every HTTP REST API delivers its response by a tuple of So I think of something like this: def _process_response(self, resp):
result = self._try_to_serialize_response(resp)
result.status_code = resp.status_code
return result |
I am just checking out your code and stumbled upon
slumber.Resource._process_response
which seems to throw away and ignore responses =! 200..299.I think there are a lot of REST APIs which supply meaningful information beyond 2xx and the API wrapper should never try to make assumptions about the API it is wrapping.
The text was updated successfully, but these errors were encountered: