mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 05:34:14 +00:00
Handle file not found gracefully
If the input file provided on the command line cannot be opened, reprt an error, rather than unwrapping.
This commit is contained in:
parent
e8dd3a0b9e
commit
5beb4ba987
1 changed files with 7 additions and 1 deletions
|
@ -325,7 +325,13 @@ fn main() {
|
|||
let stdin_handle = stdin();
|
||||
main_noninteractive(stdin_handle.lock(), false);
|
||||
},
|
||||
_ => main_noninteractive(BufReader::new(File::open(name).unwrap()), false)
|
||||
_ => {
|
||||
let file = File::open(&name).unwrap_or_else(|e| {
|
||||
eprintln!("Could not open input file '{}': {}", name, e);
|
||||
std::process::exit(1);
|
||||
});
|
||||
main_noninteractive(BufReader::new(file), false);
|
||||
}
|
||||
};
|
||||
},
|
||||
// else call the interactive version
|
||||
|
|
Loading…
Reference in a new issue