Examples of automatic exception handling

When you enable automatic exception handling in conditions, the rule engine handles specific subclasses so that rule processing can continue after exceptions are thrown. You can understand the logic behind automatic exception handling by reviewing examples.

With automatic exception handling in conditions, unknown values for Boolean expressions are resolved by using the following three-valued logic that applies for all combinations of Boolean expressions that can result in an exception:

The image contains the three-valued logic for the and, or, and not operators.

Simple rule condition

In the following example, if the status of the borrower is unknown, no rule action is executed.

if
   the status of 'the borrower' starts with "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

Rule condition that uses the OR operator

In the following example, if the status of the borrower is unknown and the comment of the loan contains the word duplicate, then the loan is rejected and a duplicate detected message is sent.

if 
   the status of 'the borrower' starts with "Duplicate" or the comment of 'the loan' contains "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

However, if the status of the borrower is unknown and the comment is unknown, then no rule action is taken. The loan is not rejected and the message no duplicate found is not added to the loan.

Rule condition that uses the AND operator

In the following example, if the status of the borrower is unknown and the comment in the loan contains the word duplicate, neither the then nor the else actions are taken. In other words, the loan is not rejected and the message no duplicate found is not added to the message of the loan.

if 
   the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate"
then
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;
else 
   add "no duplicate found" to the messages of 'the loan' ;

For the loan to be rejected, both expressions must be true.

If there is no ... then ...

If a collection of 4 past borrowers contains 3 borrowers for whom the where clause is false and 1 borrower for whom it is unknown, then the rule action is taken.

If there is no borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', 
then 
add "no duplicate found" to the message of 'the loan'

If there is at least one ... then ...

If a collection of past borrowers contains 3 borrowers for whom the where clause is true in 1 case, false in 1 case, and unknown in 1 case, then the rule action is taken.

If there is at least one borrower in the past borrowers of 'the loan' where the name of this borrower is the name of 'the borrower', 
then 
   reject 'the loan' ;
   add "duplicate detected" to the message of 'the loan'

Rule conditions that use the NOT operator

In the following example, if the status is unknown and the comment does not contain duplicate, the then action is taken and no duplicate found is added to the message of the loan.

if it is not true that
   (the status of 'the borrower' starts with "duplicate" and the comment of 'the loan' contains "duplicate")
then
   add "no duplicate found" to the messages of 'the loan' ;
else 
   reject 'the loan' ;
   add "duplicate detected" to the messages of 'the loan' ;

If the status is unknown and the comment contains duplicate, no rule action is executed.

Decision table

In the following example, the otherwise row to a condition column is selected when all the other conditions in the column are false. Alternatively, if one of the other conditions is unknown, then the otherwise row is not selected:

Decision table example image.

Collection of objects

If the result of the test that the object must fulfill is unknown, then this object is not added to the collection because only the objects tested true are added:

definitions
set 'duplicateBorrowers' to all borrowers where the status of each borrower starts with "duplicate" ; 

Expressions that use collections

In the following example, if the where clause is true for three borrowers and unknown for one borrower, then the rule engine considers that the condition is true because the borrower for whom the where clause is unknown is not counted. The then action is taken:

if  
	there are less than 3 borrowers where the name of each borrower is the name of 'the borrower',
then
   add “3 or less similar borrowers found" to the messages of 'the loan' ;
else
   reject 'the loan';
   add "more than 3 similar borrowers found" to the messages of 'the loan' ;

In the following example, if the where clause is true for one borrower and unknown for two borrowers, then the rule engine considers that the rule condition is false because the two borrowers for whom the where clause is unknown are not counted. The else action is taken:

if  
	there are more than 3 borrowers where the name of each borrower is the name of 'the borrower',
then
   reject 'the loan';
   add "3 or more similar borrowers found" to the messages of 'the loan' ;
else
   add "less than 3 similar borrowers found" to the messages of 'the loan' ;

Expressions that uses contain

The following example expression uses contain, which is an alternative way to test a collection. If the collection ('duplicateBorrowers') contains the object 'the borrower', then the condition is true.

definitions
	set 'duplicateBorrowers' to all borrowers where the customer status of each borrower starts with "duplicate" ;
if
    'duplicateBorrowers' contain  'the borrower' 
then
add "duplicate detected" to the messages of 'the loan' ;
	reject 'the loan' ;