summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src
diff options
context:
space:
mode:
authora14m <[email protected]>2021-04-06 00:36:00 +0200
committera14m <[email protected]>2021-04-06 00:36:00 +0200
commit6e631954634c24a02951e0325ef9535d5e764843 (patch)
tree45ec7bc113375983ab9f38a781ddf9415d3c0bde /CLI/rust/src
parent0a51021e8943432211736c2307e7434d6afc5904 (diff)
Format the IO error to include an ending line break
Diffstat (limited to 'CLI/rust/src')
-rw-r--r--CLI/rust/src/game_of_life/generators/input.rs12
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| {