Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Include HTTP status code as part of the error #105

Open
rafaduran opened this issue Oct 3, 2016 · 2 comments
Open

Include HTTP status code as part of the error #105

rafaduran opened this issue Oct 3, 2016 · 2 comments

Comments

@rafaduran
Copy link

It would be very useful to have status code on response error, but right now returned errors only provide a title and the response content.

@tomchristie
Copy link
Contributor

Yup, that seems like a reasonable request.

We can change that easily enough, here: https://github.com/core-api/python-client/blob/master/coreapi/transports/http.py#L257

Note that this is only for the case where the service returns a non-200 code, without explicitly returning a coreapi Error response. If the service explicitly returns an error then it can set the title however it wants too.

@bpereto
Copy link

bpereto commented Oct 19, 2018

hm, seams not so easy to me.
my application makes REST Api Calls and uses this client for endpoint abstraction. since I want to make the application more resilient (ex. networking issues, gateway down etc.) I need to now the occured error.

For Example:

  • 503 Service Unavailable: try request again
  • 400 Bad Request: Oops, wrong call, stop

Why do we "coerce" requests into an Coreapi Document Error? It's a Transport Error and not like a ParseError or Coreapi Schema Type Error.

For me its reasonable to let requests raise the exception. See http://docs.python-requests.org/en/master/user/quickstart/#response-status-codes

We can do a response.raise_for_status(), so I can catch that.

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

No branches or pull requests

3 participants