Error Handling with TRY/CATCH¶
Use TRY / CATCH to handle failures and optionally retry operations.
Catching failures¶
If riskyCall() throws, the fallback block produces an error object.
Retrying¶
Add RETRY n TIMES to re-run the expression before giving up.
The call is attempted three additional times. If all attempts fail, the fallback runs.
With backoff¶
TRY CALL remoteService(input) -> response
CATCH(err) RETRY 2 TIMES BACKOFF 500ms -> {
error: err.message ?? "service failed"
};
CALL and backoff semantics.)
Guardrails with ASSERT¶
Combine ASSERT to fail fast on bad states:
Tips¶
TRYwraps expressions; use it sparingly and close to the failing call.- Provide clear fallback values/objects for downstream logic.
BACKOFFunits follow host runtime defaults (e.g., ms).- Pair with
CHECKPOINTwhen you need progress markers around retries.
Try it¶
Open the pipeline-health-gating example in the playground to see ASSERT and tracing in action; adapt it to wrap TRY/CATCH around external calls in your own snippets.