improve error handling

This commit is contained in:
Chance 2025-04-01 18:05:17 -04:00 committed by BitSyndicate
parent a990d1c9c8
commit 6eae536478
5 changed files with 112 additions and 54 deletions

View file

@ -48,33 +48,39 @@ fn process_panic(info: &std::panic::PanicHookInfo<'_>) -> Result<(), Box<dyn Err
writeln!(file, "{}", render_backtrace().sanitize_path())?;
let panic_msg = format!(
"Zenyx had a problem and crashed. To help us diagnose the problem you can send us a crash report.
r#"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.
To submit the crash report:
https://github.com/Zenyx-Engine/Zenyx/issues
We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.
Thank you kindly!", log_path.display());
println!("{}", panic_msg.red().bold());
println!(
"\nFor future reference, the error summary is as follows:\n{}",
payload_str.red().bold()
Thank you kindly!"#,
log_path.display()
);
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(())
}
let final_msg = format!(
r#"{}
For future reference, the error summary is as follows:
{}"#,
panic_msg, payload_str
);
println!("{}", final_msg.red().bold());
MessageDialog::new()
.set_type(MessageType::Error)
.set_title("A fatal error in Zenyx has occurred")
.set_text(&final_msg)
.show_alert()
.map_err(|e| {
error!("Failed to show error dialog: {}", e);
e.into()
})
}
fn render_backtrace() -> String {
const HEX_WIDTH: usize = mem::size_of::<usize>() * 2 + 2;
const NEXT_SYMBOL_PADDING: usize = HEX_WIDTH + 6;