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.
This commit is contained in:
Steven Enamakel
2026-02-10 16:24:17 +05:30
parent 21bbc56e96
commit 95b7e2acce
3 changed files with 19 additions and 1 deletions
+1 -1
Submodule skills updated: 1aa59d8483...8030aef027
@@ -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" => {
+7
View File
@@ -86,6 +86,13 @@ pub enum SkillMessage {
Tick {
reply: tokio::sync::oneshot::Sender<Result<(), String>>,
},
/// Notify the skill of an error from an async operation.
Error {
error_type: String,
message: String,
source: Option<String>,
recoverable: bool,
},
/// Generic JSON-RPC call (for methods not covered by specific variants).
Rpc {
method: String,