Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue:2481 - Unhandled Exception on non-existent file #2642

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliazhorniakAMI The change seems fine to me. Although I would like to see a test case that was failing before.

}

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