You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add request and response properties to Exceptions #141
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.
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.
Activity
lovelydinosaur commentedon Jul 25, 2019
One of the intents of
httpxis 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
requestandresponsearguments, which is pretty much what we should do too.requestandresponsewould presumably be sufficient here - since we can accessurl,status_codeor whatever else.RRMoelker commentedon Jul 25, 2019
Agreed... Much cleaner solution.
For reference:
[-]Add status code and url to HttpError[/-][+]Add request and response properties to Exceptions[/+]halbow commentedon Jul 27, 2019
I'd like to take a look on this if @RRMoelker is not already implementing a solution !
RRMoelker commentedon Jul 27, 2019
Not working on a solution @halbow. So please