← All procedures
core.catch
Execute a procedure with error handling
CLI- Package
- @procedures/lib · README
- Path
["core","catch"]- CLI
mark core catch --try <any>- As data
{"$proc":["core","catch"],"input":{}}- Tags
- runs-refs
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/lib"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["core","catch"], { try: "<try>" });
console.log(JSON.stringify(result));From the command line
$ mark core catch --try <any>
As data, in a program
{ "$proc": ["core", "catch"], "input": { "try": "<try>" } }Input
| Field | Type | Required | Default | Description |
|---|
try | any | yes | | Procedure ref to try executing. Should use $when: "catch" so it's not auto-executed during hydration. Example: ```json { "$proc": ["git", "commit"], "input": { "message": "auto" }, "$when": "catch" } ``` |
handler | any | no | | Handler procedure ref called on error. Receives StepResultInfo (success, error, proc) merged with its input. Should return ContinueDecision { continue: boolean }. |
cwd | string | no | | Working directory for procedure execution |
Output
| Field | Type | Required | Default | Description |
|---|
success | boolean | yes | | True when the try operand succeeded |
result | any | no | | The result of try, or the decision of the handler |
error | string | no | | The error of try, when it failed |
continue | boolean | yes | | True when the caller can continue |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"try": {
"description": "Procedure ref to try executing. Should use $when: \"catch\" so it's not auto-executed during hydration. Example: ```json { \"$proc\": [\"git\", \"commit\"], \"input\": { \"message\": \"auto\" }, \"$when\": \"catch\" } ```"
},
"handler": {
"description": "Handler procedure ref called on error. Receives StepResultInfo (success, error, proc) merged with its input. Should return ContinueDecision { continue: boolean }."
},
"cwd": {
"description": "Working directory for procedure execution",
"type": "string"
}
},
"required": [
"try"
]
},
"output": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"description": "True when the try operand succeeded"
},
"result": {
"description": "The result of try, or the decision of the handler"
},
"error": {
"description": "The error of try, when it failed",
"type": "string"
},
"continue": {
"type": "boolean",
"description": "True when the caller can continue"
}
},
"required": [
"success",
"continue"
],
"additionalProperties": {}
}
}