From fcf8f938d23cfedccc4571056957f8309cb78791 Mon Sep 17 00:00:00 2001 From: josh rotenberg Date: Fri, 28 May 2021 07:40:56 -0700 Subject: [PATCH] use panic::set_hook to exit --- src/cmd/serve.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 11bd9bed..c5394f8a 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -161,5 +161,12 @@ async fn serve( let fallback_route = warp::fs::file(build_dir.join(file_404)) .map(|reply| warp::reply::with_status(reply, warp::http::StatusCode::NOT_FOUND)); let routes = livereload.or(book_route).or(fallback_route); + + std::panic::set_hook(Box::new(move |panic_info| { + // exit if serve panics + error!("Unable to serve: {}", panic_info); + std::process::exit(1); + })); + warp::serve(routes).run(address).await; }