Handling Exceptions
Use
This section provides information on the following
-
What happens if an exception is thrown while evaluating conditions?
-
What happens if the exception is thrown while firing an action?
-
Are checked/ unchecked exceptions handled differently?
Procedure
Exceptions While Evaluating Conditions
Exceptions thrown while evaluating conditions in a rule are considered FATAL and are broadcasted to the calling application code, wrapped in a RuleException. The RuleException Object can be obtained using the following code:
try{ // engine.invokeRuleset...
}catch(RuleException ruleException){
Exception rootException=ruleException().getRootException(); // Process Root Exception....
Exceptions While Executing Actions
Exceptions thrown when executing actions of a rule are considered NON-FATAL. The stack trace of these exceptions is printed and the Engine continues to fire the actions of other satisfied rules.
Handling Checked/ Unchecked Exceptions
Checked and unchecked exceptions are handled in the same way. Engine makes no differentiation between these two.