Skip to content

Commit

Permalink
* Updating Exception type on re-raise
Browse files Browse the repository at this point in the history
* Adding test case to validate exception is raised and error message is customized to our needs
  • Loading branch information
dmaljovec authored and bmabey committed Nov 12, 2019
1 parent c65f367 commit aa10019
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion provenance/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def _provenance_wrapper(*args, **kargs):
msg = 'The default repo is not set. '
msg += 'You may want to add the `default_repo` key to your call to `provenance.load_config.` '
msg += 'e.g., provenance\.load_config({\'default_repo\': <default repo name>, ...})'
raise Exception(msg).with_traceback(e.__traceback__)
raise AttributeError(msg).with_traceback(e.__traceback__)
else:
artifact = None

Expand Down
13 changes: 13 additions & 0 deletions tests/provenance/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ def spit(filename, content):
with open(filename, "w") as f:
f.write(content)


def test_errors_without_default_repo():
@p.provenance()
def my_add(x, y):
print("Executed")
return x + y

with pytest.raises(AttributeError) as err:
my_add(1, 4)

assert 'The default repo is not set' in err.message


def test_integration_test(repo):
@p.provenance(version=0, name='initial_data')
def load_data(filename):
Expand Down

0 comments on commit aa10019

Please sign in to comment.