chiark / gitweb /
client: Improve startup error handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 16:51:45 +0000 (17:51 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Aug 2021 16:51:45 +0000 (17:51 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/client.rs

index 426f974b8f1d38908e0207c9ed78a8aa99271edb..57709fd933f740c72ad0369b818917a64eaa9abe 100644 (file)
@@ -335,14 +335,21 @@ async fn run_client<C:HCC>(
 }
 
 #[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);