How to handle more than one business error with one Error Boundary Event

Currently, I have an error boundary event in one of the external service tasks of the BPMN. I have another external service task where I catch the error code and handle the error scenario. Now there is a requirement to use the same error boundary event for catching another business error.

Is it possible to do ? Please suggest the options.

Hi,
Are you using Camunda 7 or Camunda 8?

According to the BPMN specification, each error event includes exactly one event definition. This means, they can react to only one error. However, it is possible to reuse error codes and distinguish the errors via the error message or another process variable.
So, let’s say the error has the error code ServiceTaskError then you can raise this error at multiple points in the code of the service tasks. All will be caught by the single error event.

I hope this helps.

We are using Camunda platform v7.15.5-ee.

Could you please provide a sample to differentiate the error based on the error message(Error message 1, Error message 2)?

Below is the code that I am using to throw the exceptions.

throw new ExternalTaskException("100", "Error message 1");
throw new ExternalTaskException("100", "Error message 2");

You can assign the message to a variable. Afterward, you can use this variable like any other variables, for instance, in your service task implementation, for conditions in a gateway, or in other expressions: