Skip to content

TRY/CATCH

TRY/CATCH handles failures without aborting the whole transform. TRY is an expression, so it can be used in LET, CASE, or output templates.

When to use it

Use TRY/CATCH around risky lookups, parsing, or assertions so you can emit a safe fallback value.

Syntax

LET value = TRY parse(input.raw)
CATCH(err) => { ok: false, error: err.message };
The identifier in CATCH(...) is bound to an error object with message and type fields.

Example

TRANSFORM SafeTotals {
    LET total = TRY SUM(input.items)
    CATCH(err) => 0;

    OUTPUT { total: total };
}

Retry logic

Use RETRY with TIMES and optional BACKOFF for transient failures.

LET result = TRY fetch(input.url)
CATCH(err) RETRY 3 TIMES BACKOFF 200ms => null;

Pitfalls

  • Keep the TRY body small so errors are easy to interpret.
  • Prefer ASSERT for explicit failure conditions; use TRY/CATCH to keep the pipeline running.
  • BACKOFF units follow host runtime defaults (for example, ms).

Try it