From b398ea474905f043cfaf5f838ffe0634e4401abc Mon Sep 17 00:00:00 2001 From: Byson94 Date: Sun, 12 Oct 2025 12:47:23 +0530 Subject: [PATCH] feat: adding panic handling --- crates/ewwii/src/app.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/ewwii/src/app.rs b/crates/ewwii/src/app.rs index a3bd758..e187eab 100644 --- a/crates/ewwii/src/app.rs +++ b/crates/ewwii/src/app.rs @@ -849,7 +849,13 @@ impl App { match req { PluginRequest::RhaiEngineAct(func) => { let mut cp = cp.borrow_mut(); - cp.action_with_engine(func); + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + cp.action_with_engine(func) + })); + + if let Err(e) = result { + log::error!("Panic in Rhai closure: {:?}", e); + } } PluginRequest::ListWidgetIds(res_tx) => { let wgs_guard = wgs.lock().unwrap();