From 95b7e2acce1a397ac1b501daa2b32015c8209f32 Mon Sep 17 00:00:00 2001 From: Steven Enamakel Date: Tue, 10 Feb 2026 16:24:17 +0530 Subject: [PATCH] Enhance error handling in skill message processing - Added a new `Error` variant to the `SkillMessage` enum to notify skills of errors from async operations, including error type, message, source, and recoverability. - Updated the `handle_message` function to handle `SkillMessage::Error`, invoking the `onError` JavaScript handler and logging any failures in the handler execution. - Updated subproject commit reference in the skills directory. --- skills | 2 +- src-tauri/src/runtime/qjs_skill_instance.rs | 11 +++++++++++ src-tauri/src/runtime/types.rs | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/skills b/skills index 1aa59d848..8030aef02 160000 --- a/skills +++ b/skills @@ -1 +1 @@ -Subproject commit 1aa59d8483918e467eb416270c4e1c8f6ef73fe2 +Subproject commit 8030aef027b7227b2fd63bf1e31bdf9d8e806383 diff --git a/src-tauri/src/runtime/qjs_skill_instance.rs b/src-tauri/src/runtime/qjs_skill_instance.rs index e57d5c234..795752dcd 100644 --- a/src-tauri/src/runtime/qjs_skill_instance.rs +++ b/src-tauri/src/runtime/qjs_skill_instance.rs @@ -459,6 +459,17 @@ async fn handle_message( let result = handle_js_void_call(ctx, "onTick", "{}").await; let _ = reply.send(result); } + SkillMessage::Error { error_type, message, source, recoverable } => { + let args = serde_json::json!({ + "type": error_type, + "message": message, + "source": source, + "recoverable": recoverable, + }); + if let Err(e) = handle_js_void_call(ctx, "onError", &args.to_string()).await { + log::warn!("[skill:{}] onError() handler failed: {e}", skill_id); + } + } SkillMessage::Rpc { method, params, reply } => { let result = match method.as_str() { "oauth/complete" => { diff --git a/src-tauri/src/runtime/types.rs b/src-tauri/src/runtime/types.rs index 2abe6945c..7616e6065 100644 --- a/src-tauri/src/runtime/types.rs +++ b/src-tauri/src/runtime/types.rs @@ -86,6 +86,13 @@ pub enum SkillMessage { Tick { reply: tokio::sync::oneshot::Sender>, }, + /// Notify the skill of an error from an async operation. + Error { + error_type: String, + message: String, + source: Option, + recoverable: bool, + }, /// Generic JSON-RPC call (for methods not covered by specific variants). Rpc { method: String,