error

utility

Throws an error with a message

Syntax

error(message)

Parameters

message (string)

The error message to throw

Returns

never

This function throws an error and does not return

Examples

Throw error for invalid data
Input:
if .age < 0 then error("Invalid age") else . end
Output:
Error: Invalid age
Validate price is positive
Input:
if .price <= 0 then error("Price must be positive") else . end
Output:
Error: Price must be positive

The error() function throws an error with a custom message, halting execution.

Usage

Use error() to enforce data validation rules, signal invalid states, or provide meaningful error messages for debugging.

Related Functions