Try a statement and if the statement fails with an error, then the error is returned. It is also possible to catch only specific errors.

It is not possible to catch internal errors. Such errors should never happen, unless something is really wrong with at least one node.

This function does not generate a change.


try(statement, [e0, e1, ..., eX])


Argument Type Description
statement any (required) The statement to try.
e0, e1, …, eX int/raw (optional) Only catch specific errors, if omitted, catch all errors. Both error codes and names are accepted.

Return value

The value for the specified statement, or an error if the statement has failed.


This code shows some return values for try():

    is_err( try( x = (1/0) )),
    is_err( try( (1/0), zero_div_err() )),

Return value in JSON format