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(()) }