Page tree

The term exception is shorthand for the phrase "exceptional event".

An exception is an event that occurs during the execution of a program, which disrupts the normal flow of the program's instructions. This is an unexpected error and different from an error condition that has been anticipated and for which there's a defined response.

These are some of the causes of program exceptions:

  • Division by zero
  • SQRT of a negative number
  • Invalid array index
  • Error on a call
  • Error return from called program
  • Start position or length out of range for a string operation

Scenario

It is always possible that you could experience an unexpected error as a rule set runs. If this happens due to an exception, it is often difficult to see any evidence of the crash.Usually, the only notification will appear in the system diagnostics, which is rarely visible. This differs from a more normal error that would appear in a job's history.

What we need is a method for the rule set itself to tell us that there was a problem and we can do that in a couple of ways.

  • Build a generic exception handler into the rule set. I would recommend this as a "best practice" for every rule set you write.
  • Attach an exception handler to a particular action. In a long rule chain, this becomes a lot of work and recommended only for actions that you suspect are behaving badly.

It is possible and sometimes desirable to have both a generic handler that performs a certain workflow when an exception occurs as well as a specific handler (for the same exception) that does something different. The example that follows will demonstrate this.

  • No labels