mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
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:
+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" => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user