Try
The try function attempts to evaluate an expression and returns the result if successful. If the evaluation fails, it returns null or a specified default value.
Syntax
try(<expression>, [<default_value>])Parameters
expression: The expression to evaluate.default_value(optional): A fallback value to return if the evaluation fails. If not provided, the function returnsnullby default.
Returns
- Any: The result of the evaluated expression, or the
default_valueif the evaluation fails.
Example
try(var.non_existent_variable, "default value")This function is useful for gracefully handling errors or missing values in expressions.