From 8b57bf70b00390af11a9dfd222749e7378993877 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 3 Nov 2023 03:56:08 -0400 Subject: [PATCH] handle errors better in main --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7dd429d..cee6bb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -771,7 +771,7 @@ async fn run(config: Config) -> Result<(), AnyError> { Ok(()) } -fn main() { +fn main() -> Result<(), anyhow::Error> { let begin = Instant::now(); dotenvy::dotenv().ok(); @@ -786,9 +786,13 @@ fn main() { .build() .unwrap(); - rt.block_on(run(config)).unwrap(); + if let Err(err) = rt.block_on(run(config)) { + error!(?err, "something went wrong!"); + anyhow::bail!("fatal error: {:?}", err); + } info!("finished in {:?}", begin.elapsed()); + Ok(()) } #[cfg(test)]