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 {
pub fn load(p: PathBuf) -> Result<Self> {
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);
}

Loading…
Cancel
Save