Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 10 Error Handling : The Error Process Variables

The Error Process Variables
When an error transition is taken, error data is available to activities that execute after the error transition. There are two types of process variables that contain error data, the $_error process variable and the activity error variables. Activity error variables are named $_error_<activityName>, and all activities that have an error transition are available in the Process Data panel after an error transition is taken. You can use the data in these process variables to perform the desired processing, depending upon what error occurred.
The following sections describe the two kinds of error process variables.
$_error Process Variable
The $_error process variable contains general information about the process in which the error occurred. The schema of the $_error variable is the following:
The contents of each schema item are dependent upon the activity that throws the error. The Data schema item contains activity-specific error information. You can use a coercion to change the Data element into the specific type for the activity.
When you create an error-handling procedure, you may find the data in the $_error process variable useful. You can map data from this process variable into Input items for activities in your error-handling procedure.
$_error_<activityName> Process Variables
Each activity has one or more predefined error schemas. The error schemas are displayed on the activity’s Error Output tab. Typically, there are two or three types of exceptions an activity can encounter, and these are represented as a choice element in the error output schema. For example, the following illustrates the error output schema of the Create File activity:
This activity can encounter the FileAlreadyExistsException or the FileIOException. TIBCO ActiveMatrix BusinessWorks Palette Reference describes the error schemas on the Error Output tab of all activities and lists possible causes for each error type. Refer to the description of each activity for more information about the Error Output tab.
When an error is encountered, the $_error_<activityName> process variable is created and populated with the error data. The name of the process variable is dependent upon the activity’s specified name. You can obtain the error by examining the $_error_<activityName> process variable in subsequent activities after an error transition. The following illustrates the Process Data panel that is available after the activity named MyCreateFile encounters an error:
You can use XPath expressions to determine which error occurred and handle the error accordingly. For example, in the above error schema, if the FileAlreadyExistsException error occurs, then that node is not empty. The following expression can be used to determine if the FileAlreadyExistsException occurred:
 
boolean($_error_MyCreateFile/ActivityErrors/
   ns2:FileAlreadyExistsException)
You can use the msgCode element to determine the kind of error that occurred. TIBCO ActiveMatrix BusinessWorks Error Codes lists all error codes that activities can return. You should use the error code instead of the error message text to detect and handle errors. The error code should remain constant from release to release, but the text of the message may change.

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved