Skip to content

Commit

Permalink
Fix error when using @modify_exceptions in an exception initialized…
Browse files Browse the repository at this point in the history
… without arguments
  • Loading branch information
edublancas committed Jul 13, 2023
1 parent fd1fa92 commit f0d346a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## 0.2.14dev
* [Fix] Fix error when using `@modify_exceptions` in an exception initialized without arguments

## 0.2.13 (2023-06-27)

Expand Down
4 changes: 3 additions & 1 deletion src/ploomber_core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class ValidationError(BaseException):


def _add_community_link(e):
if COMMUNITY not in e.args[0]:
if not len(e.args):
e.args = (COMMUNITY,)
elif COMMUNITY not in e.args[0]:
message = e.args[0] + COMMUNITY
e.args = (message,)

Expand Down
11 changes: 11 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ def crash():
assert exceptions.get_community_link() in str(excinfo.value)


def test_modify_exceptions_no_message():
@exceptions.modify_exceptions
def crash():
raise ValueError

with pytest.raises(ValueError) as excinfo:
crash()

assert exceptions.get_community_link() in str(excinfo.value)


def test_modify_exceptions_value_error_method():
class Something:
@exceptions.modify_exceptions
Expand Down

0 comments on commit f0d346a

Please sign in to comment.