Error Handling Operators

Error handling operators allow DataLogic rules to handle exceptions and unexpected cases gracefully.

try
throw

try

The try operator attempts to evaluate an expression and returns a fallback value if an error occurs.

Syntax

{ "try": [expression, fallback] }

Parameters

Parameter Description
expression Expression to try to evaluate
fallback Value to return if evaluation fails

Example: Safe Division

Rule:

Data:

Result:

Example: Handling Missing Data

Rule:

Data:

Result:

throw

The throw operator throws an error with a custom message, interrupting the evaluation unless caught by a try operator.

Syntax

{ "throw": "Error message" }

Parameters

Parameter Description
error_message Error message to throw

Example: Validation Error

Rule:

Data:

Result:

Example: Capturing Thrown Error

Rule:

Data:

Result: