From 0b9283a69bcebd1b9e15c4967e3eb3e3645ff30b Mon Sep 17 00:00:00 2001 From: Mo8it Date: Thu, 23 Feb 2023 15:37:18 +0100 Subject: [PATCH] Use ? --- src/main.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1e3aa3c..4cc8237 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod routes; mod states; mod templates; -use anyhow::Result; +use anyhow::{Context, Result}; use axum::{ http::StatusCode, routing::{get, get_service, Router}, @@ -26,10 +26,7 @@ async fn init() -> Result<()> { let socket_address = config .socket_address .parse::() - .unwrap_or_else(|e| { - format!("Failed to parse the socket address: {e:?}"); - process::exit(1); - }); + .context("Failed to parse the socket address: {e:?}")?; logging::init_logger( &config.log_file, @@ -59,8 +56,7 @@ async fn init() -> Result<()> { info!("Starting server"); Server::bind(&socket_address) .serve(app.into_make_service()) - .await - .unwrap(); + .await?; Ok(()) }