From: Ian Jackson Date: Sat, 7 Aug 2021 16:51:45 +0000 (+0100) Subject: client: Improve startup error handling X-Git-Tag: hippotat/1.0.0~281 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=0e590dec7b00dbdd48e5bbc2e0dbf44a4d44a52c;p=hippotat.git client: Improve startup error handling Signed-off-by: Ian Jackson --- 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);