From 14b87d415b8d6eff062b9bf284bb26f9de1305df Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Wed, 16 Jun 2021 11:18:32 -0700 Subject: [PATCH] trap errors and be nice to users --- src/sourmash/sig/__main__.py | 7 ++++++- tests/test_cmd_signature.py | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index eab898b39b..90ffa78951 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -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}'") diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index e243234de0..9de8e89267 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -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): @@ -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