Skip to content

Commit

Permalink
Handle missing input file explicitly
Browse files Browse the repository at this point in the history
Check for and raise an exception when the user passes a
non-existing file as input. This makes such errors easier
to identify, as opposed to the code path and exception that
is raised with a non-existing file is passed (which also happens
to be the same exception raised when a non-XLSX file is passed,
making this error confusing).
  • Loading branch information
brandonrobertz committed Nov 25, 2021
1 parent 79754f4 commit 5a14efc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xlsx2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,8 @@ def convert_recursive(path, sheetid, outfile, kwargs):
try:
if os.path.isdir(options.infile):
convert_recursive(options.infile, sheetid, outfile, kwargs)
elif not os.path.exists(options.infile):
raise InvalidXlsxFileException("Input file not found!")
else:
xlsx2csv = Xlsx2csv(options.infile, **kwargs)
if options.sheetname:
Expand Down

0 comments on commit 5a14efc

Please sign in to comment.