forked from nonsensical-dev/zenyx-engine
update panic handler with system information
This commit is contained in:
parent
ad4cef9739
commit
bff7aff98c
4 changed files with 47 additions and 78 deletions
|
@ -46,7 +46,7 @@ fn process_panic(info: &std::panic::PanicHookInfo<'_>) -> Result<(), Box<dyn Err
|
|||
};
|
||||
|
||||
writeln!(file, "{}", payload_str)?;
|
||||
writeln!(file, "{}", render_backtrace().sanitize_path())?;
|
||||
writeln!(file, "{}", capture_backtrace().sanitize_path())?;
|
||||
|
||||
let panic_msg = format!(
|
||||
r#"Zenyx had a problem and crashed. To help us diagnose the problem you can send us a crash report.
|
||||
|
@ -54,8 +54,7 @@ fn process_panic(info: &std::panic::PanicHookInfo<'_>) -> Result<(), Box<dyn Err
|
|||
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
|
||||
|
||||
https://codeberg.org/Caznix/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!"#,
|
||||
|
@ -72,66 +71,28 @@ For future reference, the error summary is as follows:
|
|||
|
||||
println!("{}", final_msg.red().bold());
|
||||
|
||||
MessageDialog::new()
|
||||
if let Err(e) = 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;
|
||||
|
||||
let mut backtrace = String::new();
|
||||
let bt = Backtrace::new();
|
||||
let symbols = bt
|
||||
.frames()
|
||||
.iter()
|
||||
.flat_map(|frame| {
|
||||
let symbols = frame.symbols();
|
||||
if symbols.is_empty() {
|
||||
vec![(frame, None, "<unresolved>".to_owned())]
|
||||
} else {
|
||||
symbols
|
||||
.iter()
|
||||
.map(|s| {
|
||||
(
|
||||
frame,
|
||||
Some(s),
|
||||
s.name()
|
||||
.map(|n| n.to_string())
|
||||
.unwrap_or_else(|| "<unknown>".to_owned()),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let begin_unwind = "rust_begin_unwind";
|
||||
let begin_unwind_start = symbols
|
||||
.iter()
|
||||
.position(|(_, _, n)| n == begin_unwind)
|
||||
.unwrap_or(0);
|
||||
for (entry_idx, (frame, symbol, name)) in symbols.iter().skip(begin_unwind_start).enumerate() {
|
||||
let ip = frame.ip();
|
||||
let _ = writeln!(backtrace, "{entry_idx:4}: {ip:HEX_WIDTH$?} - {name}");
|
||||
if let Some(symbol) = symbol {
|
||||
if let (Some(file), Some(line)) = (symbol.filename(), symbol.lineno()) {
|
||||
let _ = writeln!(
|
||||
backtrace,
|
||||
"{:3$}at {}:{}",
|
||||
"",
|
||||
file.display(),
|
||||
line,
|
||||
NEXT_SYMBOL_PADDING
|
||||
);
|
||||
}
|
||||
.show_confirm() {
|
||||
error!("Failed to show message dialog: {e}")
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
fn capture_backtrace() -> String {
|
||||
let mut backtrace = String::new();
|
||||
let sysinfo = crate::metadata::SystemMetadata::current();
|
||||
backtrace.push_str(&sysinfo.verbose_summary());
|
||||
|
||||
let trace = backtrace::Backtrace::new();
|
||||
let message = format!("\nBacktrace:\n\n");
|
||||
backtrace.push_str(&message);
|
||||
backtrace.push_str(&format!("{trace:?}"));
|
||||
|
||||
|
||||
|
||||
backtrace
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue