Improve error message when failing to run egui_demo_app (#7567)
This commit is contained in:
parent
4683d91653
commit
e9898e4932
|
|
@ -8,7 +8,7 @@
|
||||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator, can give 20% speedups: https://github.com/emilk/egui/pull/7029
|
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; // Much faster allocator, can give 20% speedups: https://github.com/emilk/egui/pull/7029
|
||||||
|
|
||||||
// When compiling natively:
|
// When compiling natively:
|
||||||
fn main() -> eframe::Result {
|
fn main() {
|
||||||
for arg in std::env::args().skip(1) {
|
for arg in std::env::args().skip(1) {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--profile" => {
|
"--profile" => {
|
||||||
|
|
@ -62,11 +62,27 @@ fn main() -> eframe::Result {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
eframe::run_native(
|
let result = eframe::run_native(
|
||||||
"egui demo app",
|
"egui demo app",
|
||||||
options,
|
options,
|
||||||
Box::new(|cc| Ok(Box::new(egui_demo_app::WrapApp::new(cc)))),
|
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")]
|
#[cfg(feature = "puffin")]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue