Catches
The error handling mechanism allows recovery when a step encounters an error.
Step-Level Catches
Steps define error handling via catches, which is a list of Step objects:
steps:
- id: step1
uses: acts.core.irq
params:
key: act1
catches:
# Match specific error code
- uses: acts.core.msg
if: $ecode() == 'err1'
params:
key: catch_err1
# Match all unhandled errors
- uses: acts.core.msg
params:
key: catch_others
Error Handling Flow
- An activity in a step triggers an error (via
EventAction::Errororacts.core.action) - The engine checks the
catcheslist conditions in order - Executes the corresponding handler when the first matching catch is found
- After handling, the step continues normal execution
- If no catch matches, the error propagates upward
Error Code
Error codes are passed via ecode:
#![allow(unused)]
fn main() {
let mut options = Vars::new();
options.set("ecode", "err1");
rt.do_action2(&pid, &tid, EventAction::Error, options).unwrap();
}
Use $ecode() in the catch if condition to get the error code.