From 9f142ab81cd7c108df7e18f129b38ce9fb9d1138 Mon Sep 17 00:00:00 2001 From: Sergio <77530549+sergi0g@users.noreply.github.com> Date: Sat, 15 Mar 2025 12:15:33 +0200 Subject: [PATCH] fix: add error message when app fails to bind to port --- src/server.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/server.rs b/src/server.rs index 8df3694..8b5b004 100644 --- a/src/server.rs +++ b/src/server.rs @@ -19,6 +19,7 @@ use xitca_web::{ use crate::{ check::get_updates, config::Theme, + error, structs::update::Update, utils::{ json::{to_full_json, to_simple_json}, @@ -79,12 +80,16 @@ pub async fn serve(port: &u16, ctx: &Context) -> std::io::Result<()> { .at("/", get(handler_service(_static))) .at("/*", get(handler_service(_static))); } - app_builder + match app_builder .enclosed_fn(logger) .serve() - .bind(format!("0.0.0.0:{}", port))? - .run() - .wait() + .bind(format!("0.0.0.0:{}", port)) + { + Ok(r) => r, + Err(_) => error!("Failed to bind to port {}. Is it in use?", port), + } + .run() + .wait() } async fn _static(data: StateRef<'_, Arc>>, path: PathRef<'_>) -> WebResponse {