Uh oh!
There was an error while loading. Please reload this page.
Rename HTTPError to RequestError, introduce HTTPStatusError - #869
Conversation
7247ce4 to
e003e6bCompare
|
florimondmanca
commented
Mar 21, 2020
@sileht Seems like Travis is under scheduled maintenance right now:
It seems your build should start automatically once maintenance is over. :-) |
florimondmanca
left a comment
There was a problem hiding this comment.
Thanks! This is looking great to me already.
Any places in the docs that need updating?
Also going to ask a review from @tomchristie on this API change. :)
florimondmanca
commented
Mar 21, 2020
Going to try and trigger the Travis CI build... |
sileht
commented
Mar 23, 2020
That's surprise me, but I didn't find any reference of HTTPError in the documentation. |
florimondmanca
left a comment
There was a problem hiding this comment.
LGTM. :-) I also think this is definitely an improvement over the ambiguity of HTTPError as the base exception class in HTTPX.
Waiting for some more feedback before merging…
Possible follow-up work might be adding documenting exception classes that are exposed on httpx.[...] to the docs, since I believe we've been considering them as public API for a while.
HTTPError to RequestError, introduce HTTPStatusErrorUh oh!
There was an error while loading. Please reload this page.
962c7e7 to
becaa15Comparesileht
commented
Mar 28, 2020
I added a commit with some basic doc. |
Thanks!
Ideally, can we move this to a separate PR? In general we try to have one PR do one thing, but this one PR already does two things… :-) This doc addition is small, but I've got a bunch of copy nits, and it'd be better not to mix with this feature PR (which is ready to be merged without the docs addition). (I'm also wondering if exceptions docs wouldn't be better served by adding an |
609205f to
1de291bComparesileht
commented
Mar 28, 2020
I have split it. |
Fixes #867Unlike HTTPStatusError, HTTPError name is not always related to HTTP status code >= 400. The base class is renamed RequestError, to avoid confusion with HTTPStatusError. Related #867
florimondmanca
left a comment
There was a problem hiding this comment.
A quick suggestion about something I hadn't clicked about before :-)
Uh oh!
There was an error while loading. Please reload this page.
florimondmanca
left a comment
There was a problem hiding this comment.
Another improvement suggestion… Sorry for submitting this in pieces!
| """ | ||
| HTTP Status Error. | ||
| """ | ||
There was a problem hiding this comment.
Since HTTPStatusError will in practice always both have a .request and a .response attached, we should probably ensure this by overriding the constructor?
This will help type checkers understand that these attributes aren't Optional in this case. (Otherwise, accessing eg exc.response.status_code would raise a type checking error like Item "None" of "Optional[Response]" has no attribute "status_code".)
| def__init__(self, *args: typing.Any, response: "Response") ->None: | |
| super().__init__(*args) | |
| self.request: "Request"=response.request | |
| self.response: "Response"=response |
(The type comments are important to override the annotations from the base class.)
florimondmanca
commented
Jul 16, 2020
I'm going to close this for now — there's been some changes and improvements since March in the realm of the exception hierarchy, and I think we might need to properly discuss and agree on the changes proposed here beforehand. Filed #1064. Either way, @silehtthank you so much for putting time into this. This is definitely super valuable and I'm sure we'll be able to reuse this very soon! |
* Add failing tests * Use SSL context for "wss" scheme * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: Tom Christie <tom@tomchristie.com>
feat: introduce HTTPStatusError
Fixes #867
feat: rename HTTPError to RequestError
Unlike HTTPStatusError, HTTPError name is not always related to HTTP status code >= 400.
The base class is renamed RequestError, to avoid confusion with
HTTPStatusError.
Related #867