From d18e44d3b934bc5f317c9335a9dc00a00c4d33ab Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Thu, 5 Nov 2020 19:05:41 +0100 Subject: [PATCH] Print out the error messages more readable --- sfsmcctl/src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sfsmcctl/src/main.rs b/sfsmcctl/src/main.rs index 105649b..5fa7574 100644 --- a/sfsmcctl/src/main.rs +++ b/sfsmcctl/src/main.rs @@ -177,12 +177,20 @@ async fn main() -> Result<(), Box> { // 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(())