Error management with BOS

philippe.ozil's picture
philippe.ozil
Blog Categories: 

How do you deal with connector errors during the execution of your BOS processes?

This article will present two different ways to deal with errors in your processes: error events and exceptions. We will provide an example for each, and we will give you their pros and cons so you can choose the one that best fits your needs.

Sending and Receiving error events

This method allows you to associate a error with a name to a connector.  If the connector fails, the process will catch that error with a boundary error event associated to that error name.

Error handling process diagram

Error handling with a boundary error event

This will provide an alternate path that is taken to deal with your error.

However, this method has some major drawbacks:

  • One can only associate a single named error to a connector, even if it can throw different types of errors. For example, for a database query connector, the server might be down or your query’s syntax might be incorrect, but the error raised by the failed connector will be the same.
  • Upon receiving the error signal, you will no longer have access to the name of the error that occurred.

Throwing and Catching Exceptions

Another solution which is more complex, but also more powerful, is to use Java exceptions for error handling.

In this case, if you are developing your own connectors and using the Bonita API to execute some tasks, you can catch the exceptions that are raised by your connector.

Here is an example of a process that executes a task via a subprocess:

Exception handling process diagram

Exception handling via a subprocess

In this example the parent process will execute a "Caller step."

This caller step will launch the subprocess and execute the “Exception throwing step” with this method:

runtimeAPI.executeTask(activity.getUUID(), false);

This automated task will execute a connector that throws a Java Exception. This exception will be then be thrown by the execute task method and can be used to provide appropriate error handling.

You can log the error and even store the Exception object as a reference to the last error that occurred.

Errors happen - so it's useful to deal with them in advance with boundary events or exception handling.

You may download the example processes from the contribution page here: Error management sample processes for BOS 5.5.1

Comments

Submitted by ccolacil on Thu, 01/23/2014 - 11:49

How do one need to create the subprocess? and how is it connected to the caller step?

Submitted by Riet1939 on Thu, 02/04/2016 - 09:03

Link corrupted.
Is there an up-to-date example working with bonita BPM 7.1 ?

Submitted by sithara_1989699 on Mon, 01/11/2021 - 07:40

This bos file cannot be downloaded. Please provide another link to access this example.

Submitted by delphine.coille... on Fri, 01/22/2021 - 09:22

Hi all,

the example will be updated to fit with Bonita 2021.1. which will be released on January 28th. Thanks for your patience until then :-)

Notifications