Print out the error messages more readable

This commit is contained in:
Elias Schriefer 2020-11-05 19:05:41 +01:00
parent 2cab09d30b
commit d18e44d3b9

View File

@ -177,12 +177,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO:
// Perform operations
match action {
"start" => object.start().await?,
"stop" => object.stop().await?,
"restart" => object.restart().await?,
"is-running" => info!("Service at path {} is{} running", path, if !object.is_running().await {"n't"} else {""}),
let res = match action {
"start" => object.start().await,
"stop" => object.stop().await,
"restart" => object.restart().await,
"is-running" => {
info!("Service at path {} is{} running", path, if !object.is_running().await {"n't"} else {""});
Ok(())
},
_ => unreachable!("unknown action")
};
if let Err(err) = res {
error!("{:?}", err);
std::process::exit(1);
}
Ok(())