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?
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:
Syntax
try{ // engine.invokeRuleset... }catch(RuleException ruleException){ Exception rootException=ruleException().getRootException(); // Process Root Exception....
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.
Example
If an exception occurs while performing action B (in Rule1), then a message exception firing Rule1 will be printed on console along with stack trace. The Engine will continue to perform actions D & E of Rule2. Action C of Rule1 will however NOT be performed.
Rule1 |
3 actions, say A, B, C |
Priority High |
|
Rule2 |
2 actions say D, E |
Priority Medium |
Checked and unchecked exceptions are handled in the same way. Engine makes no differentiation between these two.