Catching errors by using error event handlers

Use error event handlers to catch errors at any point in a client-side human service and to implement error handling logic for these errors. To catch a specific error, you can set the implementation error properties in the error event handler by specifying the error code and mapping the error data to a specified variable.

About this task

Error event handlers that are defined in a hierarchy of nested client-side human services are not visible to all the services in the hierarchy. An error event handler that is defined in a nested client-side human service catches errors from the service in which it is defined and from all the nested services below it. For more information about embedded client-side human services, see Reusing client-side human services.
Depending on what logic you implement in the error event handler, the execution of the nested client-side human service can end differently.
Stay-On-Page Event Stay-On-Page Event
When you use a stay-on-page event after a coach in the error event handler, the stay-on-page event takes the flow back to the latest displayed coach in the service that contains the error event handler or in an ancestor client-side human service. The stay-on-page event does not return the flow to a coach within the error event handler. The coach to which the flow is returned is determined from the client-side human service where the error is caught, not where it is thrown.
End Event End Event
When you use an end event in the error event handler, the end event ends the flow of the nested service, and the execution continues in the parent service, following the flow out of the nested service activity.
Error End Event Error End Event
When you use an error end event in the error event handler, the error end event ends the flow of the nested service, but the execution can continue in the parent service if it catches the error that is thrown.

Procedure

To add an error event handler to the client-side human service:

  1. Open the client-side human service that you want to work with.
  2. In the Diagram view, add an event handler Event handler tool.
    An error event trigger is assigned and the handler changes to an Error event handler.
  3. By default, the error event is set to catch all errors. To catch a specific error:
    1. In the Implementation > Behavior properties, select Catch specific errors.
    2. Click the Error code picker to select the error code for the error to be caught.
      For example, to catch a task-ownership specific error, select the error code BPMTaskOwnerError.
    3. Click the Error mapping picker to map the error data to an error mapping variable that was previously defined in the Variables view.
  4. Double-click the error event handler, and then implement your error handling logic.
    • You can declare additional private variables in the error event handler that are visible only to the event handler.
    • You can use a coach to display the error to the user.
  5. Optional: To define multiple error event handlers that can have different error handling logic for different errors, iterate through steps 3 - 5. For each error event handler, use different error codes or error data to differentiate between the different kinds of errors.
  6. Click Save or Finish Editing.