JavaScript special statements
This recipe introduces three usages that are rather advantageous and important, try, catch, and finally functions.
Getting ready
We need a new workflow and a scriptable task inside it to try these out.
The example workflow, 06.02 JavaScript special statements
, contain all the following examples.
How to do it...
There are two sections in this recipe.
The try, catch, and finally statement
When writing any code, you want to make sure that when the code produces an error, you are still able to execute some critical operations, such as closing an open connection:
Create a scriptable task and enter the following code:
try { //Main code; System.log("Start Main"); if (error) { throw("Create Error"); } System.log("End Main"); } catch( ex ) { // error handling System.log("Error: "+ex); } finally { /...