From 0e590dec7b00dbdd48e5bbc2e0dbf44a4d44a52c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 17:51:45 +0100 Subject: [PATCH] client: Improve startup error handling Signed-off-by: Ian Jackson --- src/bin/client.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 426f974..57709fd 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -335,14 +335,21 @@ async fn run_client( } #[tokio::main] -async fn main() -> Result<(), AE> { - dedup_eyre_setup()?; - let opts = Opts::from_args(); +async fn main() { + let (ics,) =(||{ + dedup_eyre_setup()?; + let opts = Opts::from_args(); - let ics = config::read(&opts.config, LinkEnd::Client)?; - if ics.is_empty() { throw!(anyhow!("no associations with server(s)")); } + let ics = config::read(&opts.config, LinkEnd::Client)?; + if ics.is_empty() { throw!(anyhow!("no associations with server(s)")); } - opts.log.log_init()?; + opts.log.log_init()?; + + Ok::<_,AE>((ics,)) + })().unwrap_or_else(|e| { + eprintln!("hippotat: startup error: {}", &e); + process::exit(8); + }); let https = HttpsConnector::new(); let hclient = hyper::Client::builder().build::<_, hyper::Body>(https); -- 2.30.2