Skip to content

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 returns null by default.

Returns

  • Any: The result of the evaluated expression, or the default_value if the evaluation fails.

Example

Try it out below!
try(var.non_existent_variable, "default value")

This function is useful for gracefully handling errors or missing values in expressions.