From 63e98f2c0122be0e95c2753debc1ce218f2a991e Mon Sep 17 00:00:00 2001 From: rasul Date: Wed, 30 Oct 2019 16:00:52 -0500 Subject: [PATCH] more error handling and message fixing up --- src/apps.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/apps.rs b/src/apps.rs index c707c1b..63f46fe 100644 --- a/src/apps.rs +++ b/src/apps.rs @@ -14,25 +14,26 @@ pub struct Apps { impl Apps { pub fn load(p: PathBuf) -> Result { - match File::open(p.into()) { - Ok(file) => { + let path: String = String::from(p.display().to_string()); + match File::open(p) { + Ok(mut file) => { let mut buf = String::new(); if let Err(e) = file.read_to_string(&mut buf) { - error!("unable to read apps file: {}: {:?}", p.display(), e); + error!("unable to read apps file: {}", path); return Err(Box::new(e)); }; match toml::from_str(&buf) { Ok(t) => Ok(t), Err(e) => { - error!("Invalid toml in apps file: {}: {:?}", p.display(), e); + error!("Invalid toml in apps file: {}", path); Err(Box::new(e)) } } } Err(e) => { - error!("Unable to open apps file: {}: {:?}", p.display(), e); + error!("Unable to open apps file: {}", path); Err(Box::new(e)) } } @@ -49,7 +50,8 @@ impl Apps { for app in self.apps() { if app.wait.unwrap_or(false) { if let Err(e) = app.wait_start() { - error!("app failed to start: {}: {:?}", &app.name, e); + error!("app failed to start: {}", &app.name); + error!("{:?}", e); } } else { let name = app.name.clone(); @@ -60,7 +62,10 @@ impl Apps { } procs.push(proc); } - Err(e) => error!("app failed to start: {}: {:?}", name, e), + Err(e) => { + error!("app failed to start: {}", name); + error!("{:?}", e); + } }; } } @@ -89,7 +94,8 @@ impl Apps { match Proc::start(proc.app) { Ok(p) => newprocs.push(p), Err(e) => { - error!("error restarting {}: {:?}", name, e); + error!("error restarting {}", name); + error!("{:?}", e); if hold { holds = Some(holds.unwrap_or(0) - 1); }