try-catch

Syntax

try{ 
    statements 
} 
catch(ex){ 
    statements 
}

Details

If an exception occurs during the execution of the try clause, the error message is stored in the variable ex, and the catch clause is executed.

If after executing the try clause, no exception occurs, then the catch clause is skipped.

Examples

1/`7
// output
Arguments for div method can not be string.

try {1/`7} catch(ex){print "oops, please make sure they are all numbers"};
// output
oops, please make sure they are all numbers

ex;
// output
"SYSTEM_Operator" : "Arguments for div method can not be string."