Skip to main content

$error

$error(message?) -> undefined
Compact type signature<s?:x>
Browse categories

Source: JSONata

Documentation

$error() always terminates evaluation by throwing an error. Use it when the mapping cannot continue and you want to raise a deliberate failure with an optional message.

This helper belongs to Diagnostics And Errors: unlike $warn(), $info(), or $trace(), it does not continue after recording a diagnostic. It stops execution.

Examples

Abort evaluation with an error

Input

null

Expression

$error("Unsupported plan")

Result

Error (code D3137): Unsupported plan