MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / send_panic_dialog_via_callback

Function send_panic_dialog_via_callback

frontend/wrapper/src/lib.rs:84–114  ·  view source on GitHub ↗
(panic_info: String)

Source from the content-addressed store, hash-verified

82
83 return;
84 }
85 }
86
87 EDITOR_HAS_CRASHED.store(true, Ordering::SeqCst);
88
89 log::error!("{info}");
90
91 // Prefer using the raw JS callback to avoid mutex lock contention inside the panic hook.
92 if let Err(info) = send_panic_dialog_via_callback(info) {
93 send_panic_dialog_deferred(info);
94 }
95}
96
97fn send_panic_dialog_via_callback(panic_info: String) -> Result<(), String> {
98 let message = PanicDialogMessage::DisplayDialogPanic { panic_info: panic_info.clone() };
99 let Ok(message_data) = serde_wasm_bindgen::to_value(&message) else {
100 log::error!("Failed to serialize crash dialog panic message");
101 return Err(panic_info);
102 };
103
104 PANIC_DIALOG_MESSAGE_CALLBACK.with(|callback| {
105 let callback_ref = callback.borrow();
106 let Some(callback) = callback_ref.as_ref() else {
107 return Err(panic_info);
108 };
109
110 if let Err(error) = callback.call2(&JsValue::null(), &JsValue::from("DisplayDialogPanic"), &message_data) {
111 log::error!("Failed to send crash dialog panic message to JS: {error:?}");
112 return Err(panic_info);
113 }
114
115 Ok(())
116 })
117}

Callers 2

panic_hookFunction · 0.85

Calls 1

as_refMethod · 0.45

Tested by

no test coverage detected