ERROR

Description

Throws an exception with a custom message, optionally based on a specified condition. If a condition is provided, an exception is thrown only if the condition evaluates to TRUE.

Syntax

ERROR(…[message, condition_optional]) -> Error

Parameters

ParameterData TypeRequiredDescription
… messageStringYesThe error message for the exception to be thrown when the condition is met.
… condition_optionalBooleanNoA logical expression that determines whether the error should be triggered. If omitted, the error is always raised with the provided message.

Examples

ERROR(
    "Amount must be a number", NOT(IS_NUMERIC(Amount)),
    "Amount must be greater than zero", Amount <= 0
)
-- First pair: Raises an error if Amount is not a number.
-- Second pair: Raises an error if Amount is less than or equal to zero.
ERROR("Invalid")
-- Raises an error with the message "Invalid" unconditionally.

Related Formulas