wait for user input before crash after init_assets() error

This commit is contained in:
xeon 2024-05-30 21:38:05 +03:00
parent e84cad1f79
commit 27ca664829

View file

@ -1,3 +1,5 @@
use std::io::{stdin, Read};
use anyhow::Result; use anyhow::Result;
use tracing::Level; use tracing::Level;
@ -15,7 +17,10 @@ use logging::{init_logging, init_system_logging};
async fn main() -> Result<()> { async fn main() -> Result<()> {
init_logging(); init_logging();
init_config(); init_config();
init_assets()?; if let Err(err) = init_assets() {
tracing::error!("Error occurred during assets initialization: {err}");
on_critical_fault();
}
let span = tracing::span!(Level::DEBUG, "main"); let span = tracing::span!(Level::DEBUG, "main");
let _enter = span.enter(); let _enter = span.enter();
@ -26,3 +31,10 @@ async fn main() -> Result<()> {
net::gateway::listen(&CONFIGURATION.gateway_endpoint).await net::gateway::listen(&CONFIGURATION.gateway_endpoint).await
} }
fn on_critical_fault() {
eprintln!("Critical error occurred, press any key to exit...");
let _ = stdin().read(&mut [0u8]).unwrap();
std::process::exit(1);
}