JS.10.4 The 'try-catch' Statement

The “try-catch” construction allows you to catch a script error before it causes report execution to fail. To catch an error, place the desired sequence of code inside a “try” block. If any line of this “try” code generates an error, program execution immediately jumps to the code in the “catch” block.

try {

  // Code to try

}

catch(err) {

  // Alternative code for case of error

}

finally {

  // Code to execute in either case

}

The “err” parameter contains the exception message that was generated by the try block. The “finally” block contains code to be executed whether an error occurred or not. The “catch” block and “finally” block are optional, but cannot both be omitted.

<< JS.10.3 The 'if' Statement © 1996-2013 InetSoft Technology Corporation (v11.5) JS.10.5 Iteration Statements >>