httpcore icon indicating copy to clipboard operation
httpcore copied to clipboard

Raise exception with cause exception

Open CzBiX opened this issue 8 months ago • 5 comments

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)

CzBiX avatar May 28 '24 17:05 CzBiX