Skip to content

Commit 23c87f6

Browse files
SuchAFuriousDeathkjarosh
authored andcommitted
chore: Simplify code using PanicHookInfo::payload_as_str
1 parent 493e2cf commit 23c87f6

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

desktop/src/main.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,8 @@ fn panic_hook(info: &PanicHookInfo) {
8181
}
8282
});
8383

84-
// [NA] Let me just point out that PanicInfo::message() exists but isn't stable and that sucks.
85-
let panic_text = info.to_string();
86-
let message = if let Some(text) = panic_text.strip_prefix("panicked at '") {
87-
let location = info.location().map(|l| l.to_string()).unwrap_or_default();
88-
if let Some(text) = text.strip_suffix(&format!("', {location}")) {
89-
text.trim()
90-
} else {
91-
text.trim()
92-
}
93-
} else {
94-
panic_text.trim()
95-
};
84+
let message = info.payload_as_str().unwrap_or("panic occurred");
85+
9686
if rfd::MessageDialog::new()
9787
.set_level(rfd::MessageLevel::Error)
9888
.set_title("Ruffle")

0 commit comments

Comments
 (0)