Fix read_to_string to propagate error back up stack instead of panicing
@@ -46,8 +46,7 @@ pub fn start(
}
// read our template from file
- let template = read_to_string(&template_path)
- .expect(&format!("something went wrong reading: {:?}", template_path));
+ let template = read_to_string(&template_path)?;
// create a "data" json struct
let mut data = json!({});
@@ -59,8 +58,8 @@ pub fn start(
// we should always have a default.toml, would be nice to "autodiscover" based on package name,
// for now assume we're working in the plan dir if --default-toml not passed
- let default_toml = read_to_string(&default_toml_path)
- .expect(&format!("Something went wrong reading: {:?}", &default_toml_path));
+ let default_toml = read_to_string(&default_toml_path)?;
+
// merge default into data struct
merge(&mut data, toml_to_json(&default_toml));
@@ -71,8 +70,7 @@ pub fn start(
// print helper message, maybe only print if '--verbose'? how?
ui.begin(format!("Importing user.toml: {:?}", path))?;
}
- read_to_string(path)
- .expect(&format!("Something went wrong reading: {:?}", path))
+ read_to_string(path)?
},
None => "".to_string(),
};
@@ -86,8 +84,7 @@ pub fn start(
// print helper message, maybe only print if '--verbose'? how?
ui.begin(format!("Importing override file: {:?}", path))?;
}
- read_to_string(path)
- .expect(&format!("Something went wrong reading: {:?}", path))
+ read_to_string(path)?
},
// return an empty json block if '--mock-data' isn't defined.
// this allows us to merge an empty JSON block
