Skip to content

Commit

Permalink
trap errors and be nice to users
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Jun 16, 2021
1 parent 4f8e20c commit 14b87d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,12 @@ def extract(args):

picklist = None
if args.picklist:
picklist = SignaturePicklist.from_picklist_args(args.picklist)
try:
picklist = SignaturePicklist.from_picklist_args(args.picklist)
except ValueError as exc:
error("ERROR: could not load picklist.")
error(str(exc))
sys.exit(-1)

notify(f"picking column '{picklist.column_name}' of type '{picklist.coltype}' from '{picklist.pickfile}'")

Expand Down
4 changes: 2 additions & 2 deletions tests/test_cmd_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ def test_sig_extract_11_picklist_bad_coltype(runtmp):

err = runtmp.last_result.err
print(err)
assert "ValueError: invalid picklist column type 'BADCOLTYPE'" in err
assert "invalid picklist column type 'BADCOLTYPE'" in err


def test_sig_extract_12_picklist_bad_argstr(runtmp):
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def test_sig_extract_12_picklist_bad_colname(runtmp):

err = runtmp.last_result.err
print(err)
assert "ValueError: column 'BADCOLNAME' not in pickfile" in err
assert "column 'BADCOLNAME' not in pickfile" in err


@utils.in_tempdir
Expand Down

0 comments on commit 14b87d4

Please sign in to comment.