show dialog on panic

This commit is contained in:
Chance 2025-03-30 02:54:07 -04:00 committed by BitSyndicate
parent 43b8e75ad7
commit 2d4736f12e
6 changed files with 319 additions and 6 deletions

View file

@ -3,8 +3,10 @@ use std::fmt::Write as FmtWrite;
use std::mem;
use backtrace::Backtrace;
use native_dialog::{MessageDialog, MessageType};
use parking_lot::Once;
use regex::Regex;
use tracing::error;
static INIT: parking_lot::Once = Once::new();
@ -48,7 +50,7 @@ fn process_panic(info: &std::panic::PanicHookInfo<'_>) -> Result<(), Box<dyn Err
let panic_msg = format!(
"Zenyx had a problem and crashed. To help us diagnose the problem you can send us a crash report.
We have generated a report file at \"{}\". Submit an issue or email with the subject of \"Zenyx Crash Report\" and include the report as an attachment.
We have generated a report file at '{}'. Submit an issue or email with the subject of 'Zenyx Crash Report' and include the report as an attachment.
To submit the crash report:
@ -62,6 +64,14 @@ Thank you kindly!", log_path.display());
"\nFor future reference, the error summary is as follows:\n{}",
payload_str.red().bold()
);
if let Err(e ) = MessageDialog::new()
.set_type(MessageType::Error)
.set_title(&format!("{}",payload_str))
// wont display properly if not debug formatted??
.set_text(&format!("{:#?}", panic_msg))
.show_alert() {
error!("{e}");
}
Ok(())
}