Error handling for SnipInfo missing ressources/
@@ -72,12 +72,16 @@ impl Launcher {
pub fn info(&self) -> std::io::Result<String> {
let mut v: Vec<String> = vec![];
let filename = self.data.sniprun_root_dir.clone() + "/ressources/asciiart.txt";
- let mut file = File::open(filename)?;
+
+ if let Ok(mut file) = File::open(filename) {
let mut content = String::new();
file.read_to_string(&mut content)?;
info!("[INFO] Retrieved asciiart");
v.push(content);
v.push("\n".to_owned());
+ } else {
+ v.push(String::from("SNIPRUN\n"));
+ }
let gitscript = self.data.sniprun_root_dir.clone() + "/ressources/gitscript.sh";
let mut get_version = Command::new(gitscript);
@@ -87,6 +91,8 @@ impl Launcher {
let online_version = String::from_utf8(res.stdout).unwrap();
info!("online version available: {}", &online_version);
v.push(online_version);
+ } else {
+ v.push(String::from("Could not determine up-to-date status\n"));
}
if let Some((name, level)) = self.select() {
