diff --git a/crates/egui_demo_app/src/main.rs b/crates/egui_demo_app/src/main.rs index 48825715..37a235e8 100644 --- a/crates/egui_demo_app/src/main.rs +++ b/crates/egui_demo_app/src/main.rs @@ -8,7 +8,7 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator, can give 20% speedups: https://github.com/emilk/egui/pull/7029 // When compiling natively: -fn main() -> eframe::Result { +fn main() { for arg in std::env::args().skip(1) { match arg.as_str() { "--profile" => { @@ -62,11 +62,27 @@ fn main() -> eframe::Result { ..Default::default() }; - eframe::run_native( + let result = eframe::run_native( "egui demo app", options, Box::new(|cc| Ok(Box::new(egui_demo_app::WrapApp::new(cc)))), - ) + ); + + match result { + Ok(()) => {} + Err(err) => { + // This produces a nicer error message than returning the `Result`: + print_error_and_exit(&err); + } + } +} + +fn print_error_and_exit(err: &eframe::Error) -> ! { + #![expect(clippy::print_stderr)] + #![expect(clippy::exit)] + + eprintln!("Error: {err}"); + std::process::exit(1) } #[cfg(feature = "puffin")]