From 6bd9983ea67d6f2bbd027dc177fe674ea5a94685 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:47:06 -0700 Subject: [PATCH] Allow FileNotFoundError to be handled at the top level The removed error handling is flawed: it assumes that FileNotFoundError can only come from a missing input file (--sequences). The reality is that FileNotFoundError can also come from a missing output directory (--output). The top-level exception handler parses the filepath from the error directly, which is accurate. --- augur/index.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/augur/index.py b/augur/index.py index 883cefd37..4f77432bc 100644 --- a/augur/index.py +++ b/augur/index.py @@ -209,15 +209,11 @@ def run(args): ("?" and "-"), and other invalid characters in a set of sequences and write the composition as a data frame to the given sequence index path. ''' - try: - if is_vcf(args.sequences): - num_of_seqs = index_vcf(args.sequences, args.output) - tot_length = None - else: - num_of_seqs, tot_length = index_sequences(args.sequences, args.output) - except FileNotFoundError: - print(f"ERROR: Could not open sequences file '{args.sequences}'.", file=sys.stderr) - return 1 + if is_vcf(args.sequences): + num_of_seqs = index_vcf(args.sequences, args.output) + tot_length = None + else: + num_of_seqs, tot_length = index_sequences(args.sequences, args.output) if args.verbose: if tot_length: