Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eth_utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def wrapper(
return to_wrap(*args, **kwargs)
except old_exceptions as err:
try:
raise old_to_new_exceptions[type(err)] from err
raise old_to_new_exceptions[type(err)](err) from err
except KeyError:
raise TypeError(
"could not look up new exception to use for %r" % err
Expand Down
1 change: 1 addition & 0 deletions newsfragments/198.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pass context to new exception in ``replace_exceptions`` decorator.
4 changes: 2 additions & 2 deletions tests/decorator-utils/test_replace_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def mock_function_with_exception(old_to_new):
@replace_exceptions(old_to_new)
def function_with_exception(x):
raise TypeError
raise TypeError("Boom!")

return function_with_exception

Expand All @@ -21,5 +21,5 @@ def function_with_exception(x):
),
)
def test_decorator_replaces_exceptions(mock_function_with_exception, old_to_new, new):
with pytest.raises(new):
with pytest.raises(new, match="Boom!"):
mock_function_with_exception(old_to_new)