Events and exceptions

Such a requirement can be handled using special DML Blocks called events. You can define three types of events in a Mapping Flow: the start event, the error event and the end event. As you might guess, start and end events are executed before and after input is processed, and error events are executed when an error occurs.

The following diagram shows how events take place in the whole process of input data and output generation.

The role of events in the process of input data and output generation

Start and end events are typically used either to participate in envelope generation (for example: the start event generates the final message header while the end event builds the final message trailer) or for logging purposes (to keep the user informed of the progress of the process).

You use error events to recover from error conditions using DML code. For example, you can use an error event to extract erroneous data from the main data stream and send it to a special output. Error events provide an extension of some aspect of the regular data processing. This is why, in the diagram above, they are symbolized using the same color.

As the diagram suggests, with a Mapping Flow and an error event appropriately defined, you are able to process specifically faulty parts of the input data while normally processing the other parts. When the bad part is processed an error condition is detected and control is transferred to the error event. When this error event has been executed and provided the error recovering is active, control is transferred back to the regular processing chain.

Several families of situations lead to an error condition and trigger the error event when defined:

  • Invalid input or output data
  • Input data processed and output data generated might be checked against a set of rules. When you activate either Facet Check or Validation Rules execution, any failure is an error condition.
  • Run-time errors
  • While mapping data many run-time errors can occur. Mainly these are conversion problems: illegal instructions (zero-division), system resource exhaustion or third-party component failures.
  • The exit instruction
  • Unlike the previous described families which represent automatic behavior of the XIB engine, the exit instruction is the user-defined way to trigger error event.

When an error from one of these families is detected, the current transaction is always canceled and then control can be transferred to the error event.

Related Links