httpcore
httpcore copied to clipboard
Raise exception with cause exception
Summary
In the current logic, the original exception is discarded, which makes it hard to determine the thrown exception more precisely.
Checklist
- [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
- [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- [ ] I've updated the documentation accordingly.
Use case
try:
resp = pool.request('GET', 'https://example.com')
except ConnectError as error:
# before
assert error.__cause__ is None
# after
assert isinstance(error.__cause__, ssl.SSLError)