Rule Language Grammar : Exception Handling

Exception Handling
The BusinessEvents rule Language includes try/catch/finally blocks and has an Exception type. The try/catch/finally blocks behave like their same-name Java counterparts.
Advisory Events  You can also use the special AdvisoryEvent event type to be notified of exceptions that originate in user code but that are not caught with a catch block. To use the AdvisoryEvent, click the plus sign used to add a resource to the declaration. AdvisoryEvent is always available in the list of resources. See Chapter 10, Advisory Events.
This section describes the try/catch/finally commands.
Syntax
These combinations are allowed:
try    try {
       try_statements
      }
catch  catch (Exception identifier) {
        catch_statements
      }
finally   finally {
         finally_statements
      }
Examples
This section provides some examples to demonstrate use of exception handling.
try/finally Example

 
String localStatus = "default status";
try {
//readStatus might throw an exception
localStatus = readStatus();
} finally {
//If readStatus() throws an exception,
    //MyScorecard.status will be set to "default status"
//but the exception won't be caught here.
//Otherwise MyScorecard.status will be set to the
    //return value of readStatus()
MyScorecard.status = localStatus;
}

 
try/catch/finally Example

 
String localStatus = "default status";
try {
    //readStatus might throw an exception
    localStatus = readStatus();
} catch(Exception exp) {
    System.debugOut("readStatus() threw an exception with message"
                     + exp@message);
} finally {
    //If readStatus throws an exception,
    //MyScorecard.status will be set to "default status"
    //Otherwise MyScorecard.status will be set to the
    //return value of readStatus()
    MyScorecard.status = localStatus;
}

 
try/catch Example

 
String localStatus = "default status";
try {
    //readStatus might throw an exception
    localStatus = readStatus();
} catch(Exception exp) {
    System.debugOut("readStatus() threw an exception with message "
             + exp@message);
}
    //If readStatus throws an exception,
    //MyScorecard.status will be set to "default status"
    //Otherwise MyScorecard.status will be set to the
    //return value of readStatus()
MyScorecard.status = localStatus;