Conditional Catch Blocks

In JavaScript, a try-catch statement can include an optional if statement within the catch block, however it is not ECMAScript compliant. In SuiteScript 2.0, a script that includes a conditional catch statement executes without error. In SuiteScript 2.1, a SyntaxError is thrown for any script that includes a conditional catch statement.

Scenario

SuiteScript 2.0 Behavior

SuiteScript 2.1 Behavior

Create a try-catch statement with an if statement in the catch block:

                    try {
// do something here
} catch (e if e instanceof TypeError) { // Don't use
    log.debug("error = " , e);
} 

                  

The script completes execution without throwing an error.

The following error is generated:

SyntaxError: SyntaxError: <eval>:2:11 Expected ) but found if } catch (e if e instanceof TypeError) { // Don't use

Related Topics

General Notices