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
Arguments for div method can not be string.

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

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