From aae3c49013331ea2a3838edcac27b1f49674af66 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 18 Feb 2018 19:49:11 -0800 Subject: [PATCH] catch parse error -> question if it's a valid LCA DB --- sourmash_lib/lca/lca_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sourmash_lib/lca/lca_utils.py b/sourmash_lib/lca/lca_utils.py index fcdca0dc27..ffe8a8e93c 100644 --- a/sourmash_lib/lca/lca_utils.py +++ b/sourmash_lib/lca/lca_utils.py @@ -138,7 +138,10 @@ def load(self, db_name): xopen = gzip.open with xopen(db_name, 'rt') as fp: - load_d = json.load(fp) + try: + load_d = json.load(fp) + except json.decoder.JSONDecodeError: + raise ValueError("cannot parse database file '{}'; is it a valid LCA db?".format(db_name)) version = load_d['version'] assert version == '1.0'