Skip to content

Add request and response properties to Exceptions #141

Closed

Description

@RRMoelker

In order to gracefully handle different HttpErrors I would like to know the url and status code of the offending call. Currently I'm wrapping the httpx raise_for_status code so this is added. However I think this would be a good addition to the core HttpError exception.

So an HttpError would consist of:

  • message
  • status code
  • url

A drawback is that these additional properties may grow unwieldy as more exception handling cases are discovered. But I think some basic call information is called for.

Activity

  1. lovelydinosaur commented on Jul 25, 2019

    @lovelydinosaur
    Member

    One of the intents of httpx is to provide a broadly requests-compatible API - so looking towards what requests provides on exceptions is a good first pass here.

    Sensible their base exceptions allow for request and response arguments, which is pretty much what we should do too.

    these additional properties may grow unwieldy

    request and response would presumably be sufficient here - since we can access url, status_code or whatever else.

  2. changed the title [-]Add status code and url to HttpError[/-] [+]Add request and response properties to Exceptions[/+] on Jul 25, 2019
  3. halbow commented on Jul 27, 2019

    @halbow
    Contributor

    I'd like to take a look on this if @RRMoelker is not already implementing a solution !

  4. RRMoelker commented on Jul 27, 2019

    @RRMoelker
    Author

    Not working on a solution @halbow. So please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions