Skip to content

Commit

Permalink
Chain exception re-raise in map_exceptions (#678)
Browse files Browse the repository at this point in the history
Preserves the exception chain instead of displaying "During handling of the above exception, another exception occurred" in the traceback

Co-authored-by: Tom Christie <tom@tomchristie.com>
  • Loading branch information
zanieb and tomchristie authored May 10, 2023
1 parent b113799 commit 78756bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion httpcore/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc)
raise to_exc(exc) from exc
raise # pragma: nocover


Expand Down

0 comments on commit 78756bf

Please sign in to comment.