more error handling and message fixing up

master
rasul 5 years ago
parent d8ed14373e
commit 63e98f2c01

@ -14,25 +14,26 @@ pub struct Apps {
impl Apps { impl Apps {
pub fn load(p: PathBuf) -> Result<Self> { pub fn load(p: PathBuf) -> Result<Self> {
match File::open(p.into()) { let path: String = String::from(p.display().to_string());
Ok(file) => { match File::open(p) {
Ok(mut file) => {
let mut buf = String::new(); let mut buf = String::new();
if let Err(e) = file.read_to_string(&mut buf) { 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)); return Err(Box::new(e));
}; };
match toml::from_str(&buf) { match toml::from_str(&buf) {
Ok(t) => Ok(t), Ok(t) => Ok(t),
Err(e) => { Err(e) => {
error!("Invalid toml in apps file: {}: {:?}", p.display(), e); error!("Invalid toml in apps file: {}", path);
Err(Box::new(e)) Err(Box::new(e))
} }
} }
} }
Err(e) => { Err(e) => {
error!("Unable to open apps file: {}: {:?}", p.display(), e); error!("Unable to open apps file: {}", path);
Err(Box::new(e)) Err(Box::new(e))
} }
} }
@ -49,7 +50,8 @@ impl Apps {
for app in self.apps() { for app in self.apps() {
if app.wait.unwrap_or(false) { if app.wait.unwrap_or(false) {
if let Err(e) = app.wait_start() { 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 { } else {
let name = app.name.clone(); let name = app.name.clone();
@ -60,7 +62,10 @@ impl Apps {
} }
procs.push(proc); 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) { match Proc::start(proc.app) {
Ok(p) => newprocs.push(p), Ok(p) => newprocs.push(p),
Err(e) => { Err(e) => {
error!("error restarting {}: {:?}", name, e); error!("error restarting {}", name);
error!("{:?}", e);
if hold { if hold {
holds = Some(holds.unwrap_or(0) - 1); holds = Some(holds.unwrap_or(0) - 1);
} }

Loading…
Cancel
Save