Exception Handling
To trap errors in trigger scripts, use the try…catch…finally control structure, for example:
try {
// Code to be executed
} catch (error) {
// Code to execute there is an error
} finally {
// Optional – always execute this code
}
where:
The try block contains the code you want to run.
The catch block contains the code you want to run if an error occurs.
The finally block (optional) contains code that always runs before the control structure ends.
* 
As a best practice, use try..catch whenever possible.
Was this helpful?