Throwing an exception

If you detect an error or other situation in your message flow in which you want message processing to be ended, you can throw an exception in a message flow in two ways.

About this task

  • Use the ESQL THROW EXCEPTION statement.

    Include the THROW statement anywhere in the ESQL module for a Compute, Database, or Filter node. Use the options on the statement to code your own data to be inserted into the exception.

  • Include a THROW node in your message flow.

    Set the node properties to identify the source and content of the exception.

By using either statement options or node properties, you can specify a message identifier and values that are inserted into the message text to give additional information and identification to users who interpret the exception. You can specify any message in any catalog that is available to the integration node. See Using error logging from a user-defined extension for more information.

The situations in which you might want to throw an exception are determined by the behavior of the message flow; decide when you design the message flow where this action might be appropriate. For example, you might want to examine the content of the input message to ensure that it meets criteria that cannot be detected by the input node (which might check that a particular message format is received).

The following example uses the Example message to show how you can use the ESQL THROW statement. To check that the invoice number is within a particular range, throw an exception for any invoice message received that does not fall in the valid range.

--Check for invoice number lower than permitted range
IF Body.Invoice.InvoiceNo < 100000 THEN
   THROW USER EXCEPTION CATALOG 'MyCatalog' MESSAGE 1234 VALUES
   ('Invoice number too low', Body.Invoice.InvoiceNo);

-- Check for invoice number higher than permitted range
ELSEIF Body.Invoice.InvoiceNo > 500000 THEN
      THROW USER EXCEPTION CATALOG 'MyCatalog' MESSAGE 1235 VALUES
   ('Invoice number too high', Body.Invoice.InvoiceNo);

ELSE DO
  -- invoice number is within permitted range
  -- complete normal processing
ENDIF;