Skip to content

Commit

Permalink
issue:2481 - Unhandled Exception on non-existent file
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliya Zhornyak committed Apr 5, 2024
1 parent 760c898 commit d72dcd8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,12 +1789,18 @@ int main(int argc, char *argv[])

// TODO: for now we ignore the other filenames, only handle
// the first:
std::string arg_file = arg_files[0];
if (CLI::NonexistentPath(arg_file).empty()){
std::cerr << "The input file does not exist: " << arg_file << std::endl;
return 1;
try {
std::string arg_file = arg_files[0];
if (CLI::NonexistentPath(arg_file).empty()) {
std::cerr << "Error: The input file does not exist: " << arg_file << std::endl;
return 1;
}
return 0;
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}

std::string outfile;
std::string basename;
basename = remove_extension(arg_file);
Expand Down

0 comments on commit d72dcd8

Please sign in to comment.