Appendix C. Handling exceptions and errors 467
Mode-specific On Error
If an error occurs during a Connector Interface operation, then the On Error Hook
for the Connector mode is invoked
. This Hook is not mandatory, so having it not
enabled will not cause additional exceptions to be thrown.
After the mode-specific
On Error Hook is executed (or skipped, if not enabled)
flow continues to the
Default On Error Hook.
Default On Error
Although other error Hooks can precede it - like On Connection Failure or
Mode-Specific On Error described in the previous sections - this is the error
Hook that is ultimately called for any error-exception thrown during Connector or
If this Hook is not enabled then the AssemblyLine aborts with the error and the
On Failure Hook is invoked. However, if Default On Error is enabled, the
exception is effectively "swallowed" and control is passed to the next AL
An important part of any error handling scheme is logging. Of course, logging
has other uses as well; like passing data to other applications, or writing an
AssemblyLine audit trail. As a result, this chapter will deal with logging in more
general terms than just error handling.
TDI uses a Java API for logging called
Log4j. This flexible framework provides a
rich set of features that TDI leverages in such a way as to pass this flexibility on
to you. It is not necessary that you know how Log4j works to do logging in TDI.
However, any knowledge you do have can be directly applied to your solutions.
So without going into the gritty details, logging in log4j can be thought of in three
logger, appender, and layout.
The first part (
logger) refers to the mechanism that enables logging, and this bit
handled for you by TDI.
The second term (
appender) is also a job for TDI. This work is carried out a
logging component called, not surprisingly, an Appender. TDI provides a range of
appenders that each supports a specific log system or mechanism.
This is also true of connection failures as well, although the On Connection Failure (and possibly
Reconnect feature, if enabled) is executed first.