Skip to content

Commit

Permalink
Allow FileNotFoundError to be handled at the top level
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
victorlin committed Sep 25, 2024
1 parent bf05db8 commit 6bd9983
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions augur/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6bd9983

Please sign in to comment.