This commit is contained in:
Mo 2023-02-23 15:37:18 +01:00
parent e6b7c549e3
commit 0b9283a69b

View file

@ -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::<SocketAddr>()
.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(())
}