Handling errors in client-side human services

You can handle errors in a client-side human service by using a stand-alone error event handler or you can catch errors at a particular step by attaching a boundary error event to an individual service. To throw specific errors and end the processing of the service flow at a specified step, you can use error end events.

To catch errors, you can use either error boundary events or error event handlers. Both options provide the same capability to catch errors. The difference is where the error handling logic resides in your diagram. The error logic for error boundary events is located in the client-side human service diagram. The logic for error event handlers is located in the error event handler diagram. To move your error handling logic out of your main path logic, use error event handlers.

You can configure boundary events and error event handlers to catch all errors or specific errors. At run time, boundary events take precedence over error event handlers and specific errors take precedence over catch all errors.

You can specify error properties to catch or throw specific errors, filter on the error code for the types of errors, and map to a variable after the errors are caught.
  • The error event information is captured in the tw.error.code and tw.error.data variables. For more information, see JavaScript API for client-side human service development.
  • By mapping the error event to a variable, events with incompatible data types are filtered out and the data is captured in a local variable.
Table 1. Usage of error events in client-side human services
Icon Error event Description
This icon indicates the Error boundary event on the palette for client-side human services. Error boundary event. An intermediate error event that is attached to a service in a client-side human service. Catches errors and receives error data from the service that it is attached to. To model where the client-side human service resumes after it catches an error, you connect each error boundary event to an activity that runs the error handling logic. You can wire an error boundary event to any node.

You can attach error boundary events only to service nodes in your client-side human service. You can reposition an error boundary event inside the service. You can remove it from the service or you can move it to another service.

This icon indicates the Error event handler on the palette for client-side human services. Global error event handler that catches errors in the client-side human service and runs error handling logic. Catches all errors or specific errors. You implement error handling logic in the error handler. If you do not implement custom logic, the service ends at the step where the error occurs.

You can use multiple error event handlers in a client-side human service. For example, you can configure an error event handler to catch a specific error code and an error event handler that catches all other errors. You can then implement different logic to handle specific errors and logic to handle all other errors.

The only way to resume your client-side human service after an error event handler is entered is by using a stay-on-page event. This event resumes the client-side human service at the last coach that ran in the client-side human service. You can use error event handlers as stand-alone event handler outside a service. You can implement custom error handling logic in the error event handler for all or specific events.

This icon indicates the Error end event on the palette for client-side human services. Error end event that throws an error and ends the processing of the client-side human service. Throws a specific error and ends the processing of the service flow at a specified step. You can connect error end events to any node in a client-side human service. You can specify an error code and error data for the error.

For example, you might use an error end event when you want a particular result from a coach to end the processing of a client-side human service. If the human service is used in a business process definition (BPD), the error end event communicates the error data back to the BPD. An error intermediate event that is set up at the BPD level catches the error that is thrown by the error end event that is defined at the human service level.