diff options
Diffstat (limited to 'CLI')
| -rw-r--r-- | CLI/rust/src/game_of_life/generators/input.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/CLI/rust/src/game_of_life/generators/input.rs b/CLI/rust/src/game_of_life/generators/input.rs index dc22525..547b40e 100644 --- a/CLI/rust/src/game_of_life/generators/input.rs +++ b/CLI/rust/src/game_of_life/generators/input.rs @@ -1,6 +1,6 @@ use crate::game_of_life::opts::Opts; use crate::game_of_life::universe::Universe; -use clap::Error; +use clap::{Error, ErrorKind}; use regex::Regex; #[cfg(test)] @@ -69,7 +69,15 @@ mod new { /// and generate a new universe instance in the initial state from file #[cfg_attr(test, mockable)] fn generate_file_data(opts: Opts) -> Result<Universe, Error> { - let file = std::fs::read_to_string(opts.input.clone().unwrap())?; + let file = match std::fs::read_to_string(opts.input.clone().unwrap()) { + Ok(s) => s, + Err(e) => { + return Err(Error::with_description( + format!("{}\n", e.to_string()), + ErrorKind::Io, + )) + } + }; let data: Vec<Vec<bool>> = file .split("\n") .map(|s| { |
