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

Include HTTP status code as part of the error #105

Open

Description

@rafaduran

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.

Activity

  1. lovelydinosaur commented on Oct 3, 2016

    @lovelydinosaur
    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.

  2. 0asys commented on Oct 19, 2018

    @0asys

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions