-
-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.13: some httpcore
exceptions are missing from top level package
#1023
Comments
@iwoloschin I'm tempted to keep the base class issue to #949. But you raised an interesting point about
So, marking this as bug up for grabs. I'll retitle this issue to reduce its scope and keep any discussions on base classes scoped to #949. |
httpore
exceptions are missing from top level package
httpore
exceptions are missing from top level packagehttpcore
exceptions are missing from top level package
I made this as a separate issue because I couldn't really find any big, obvious notes that exception handling had changed for 0.13. I didn't even really understand the scope of the change after commenting in #949, after I did some digging and understood what had happened I felt it was worthwhile specifically breaking this out since it might be as simple as a bug against 0.13[.3], with the higher level discussion for #949? I'm fine either way. I realize that as this is basically all pre-release software there is always a risk of breaking changes, but this project has actually been pretty good about noting breaking changes. Honestly, httpx is such a joy to use that it would be worth dealing with breaking changes anyways, I just was hoping for more notice than "pushed a new release and...oh...it all broke" 😄 . |
Yeah, to be honest we hadn't realized the exception handling API would change so much due to the deferring of the networking layer to |
If only we were paid for fixing all of the "small" changes we make 😄 . Is most of the discussion happening in the gitter room? I can see if I can drop in there. |
Checklist
master
.Describe the bug
I believe that
HTTPError
is expected to be the base exception for all exceptions that httpx may raise? Since 0.13 this is no longer true and comments in_exceptions.py
indicate this is a bug. In real world use I have at least one bit of code that has failed due to this. I could see an argument for trying to catch a more specific error, but I think this caseHTTPError
was really nice to use.Even if users should be using more specific exceptions having a single base exception is an incredibly useful feature for any library and it'd be great if we could ensure this behavior is set for the upcoming 1.0 release.
To reproduce
The following code assumes localhost does not have any webserver running on port 80. Running on httpx 0.12 it correctly catches the
HTTPError
, running on 0.13 it does not catch the exception (httpcore.ConnectError, which doesn't appear to be properly exported in [\_\_init\_\_.py](https://github.com/encode/httpx/blob/master/httpx/__init__.py), though it is aliased in
_exceptions.py`).Expected behavior
If
HTTPError
is the base exception for httpx I'd expect catchingHTTPError
to actually catch all errors httpx may raise.Actual behavior
Instead of catching
HTTPError
it appears that httpcore errors bubble up. This breaks exception handling that expectsHTTPError
to be the base exception.Environment
The text was updated successfully, but these errors were encountered: