Catch [v1.1.04+]

Specifies the code to execute if an exception is raised during execution of a Try statement.

Catch , OutputVar
Catch , OutputVar



(Optional) The name of the output variable in which to store the value of the exception.


The commands or expressions to execute if an exception is raised.


Every use of Catch must belong to (be associated with) a Try statement above it. A Catch always belongs to the nearest unclaimed Try statement above it unless a block is used to change that behavior.

The One True Brace (OTB) style may optionally be used. For example:

try {
} catch e {

Runtime Errors

A Try-Catch statement can also be used to handle runtime errors. There are two kinds of runtime errors: those which normally set ErrorLevel, and those which normally cause the current thread to exit after displaying an error message. Loadtime errors cannot be handled, since they occur before the Try statement is executed. For backward-compatibility (and in some cases convenience), runtime errors only throw exceptions while a Try block is executing. Most commands support the use of Try-Catch; however, ErrorLevel is still set to 0 if the command succeeds.

The value that is stored in OutputVar (if present) is an exception object.

Try, Throw, Finally, Blocks, OnError()


See Try.