Error Boundary not catching the exception

Hi All. I have designed a process with a service task and a error boundary attached to it. I’m trying to throw error from service task so that the error boundary catches it. But the thing is even though i provide wrong method or do not provide authentication details, the service task is not throwing any error. How can i make service task to throw any error.
ErrorBoundary.bpmn (6.1 KB)

@Kalyani_TB, from your model bpmn error is not mapped. Configure the bpmn error details in the bpmn file and the same should be match with bpmn error thrown by service task.

image

Mapped the error but same issue. Can u pls have a look. ErrorBoundary.bpmn (6.2 KB)

You need to explicitly throw a BPMN error.
You can’t do this with connector - for this reason and many others i’d advice avoiding connectors.

For a better understanding of error handling, you can check out this tutorial.

I have unused the connector and made the service task to fail using a wrong expression. How do i make the error boundary to catch this exception.ErrorBoundary.bpmn (5.2 KB)

Is there any expression which can be used to throw bpmn error in service task in camunda modeller?

Hi @Kalyani_TB,

unfortunately, there is no way to raise a BPMN Error with an expression.

You have to code it in a Java Delegate like here: https://docs.camunda.org/manual/7.12/user-guide/process-engine/delegation-code/#throw-bpmn-errors-from-delegation-code,

or wrap the code in a Bean, that can be used in an expression or Delegate Expression.

Another option would be to use an external task and code the business logic in a programming language of your choice. Have a look into the docs about external tasks here: https://docs.camunda.org/manual/7.12/user-guide/process-engine/external-tasks/ and especially here: https://docs.camunda.org/manual/7.12/user-guide/process-engine/external-tasks/#reporting-bpmn-error.

You can find the REST API to handle external tasks here: https://docs.camunda.org/manual/7.12/reference/rest/external-task/

Hope this helps, Ingo

Thank you all for help. I have one more question. Can the error boundary catch system errors/non-bpmn errors? If yes, what additional settings do i have to do in my processErrorBoundary.bpmn (5.2 KB)

No, the ErrorBoundaryCatchEvent will only catch errors of type BpmnError. But you can simply catch all other kinds of errors/exceptions and rethrow them as BpmnError (might be bad style, but its possible).

Business error --> BPMN Error

Technical/System error --> Create Incident and then resolve the incident

Am trying to throw bpmn error using script task. But am getting below error while starting the process. Any thoughts? JavaScript is in bpmn file.ErrorBoundary.bpmn (5.3 KB)
The process could not be started. : Cannot instantiate process definition ErrorBoundary:33:55efc8ea-218b-11ea-8d40-0242ac110002: Unable to evaluate script while executing activity ‘Task_1pqlikl’ in the process definition with id ‘ErrorBoundary:33:55efc8ea-218b-11ea-8d40-0242ac110002’::1:38 Expected an operand but found error var sigValidity=execution.getVariable(“SignatureValidity”); ^ in at line number 1 at column number 38

By looking at your model I feel like you try to model a decision by using a ScriptTask and the ErrorBoundaryCatchEvent instead of using the initially declared variable to further proceed based on its value. So you are overcomplicating a minor task.

IMO, the returned boolean should be used with a XOR gateway with two outgoing sequence flows. This would be a lot cleaner and everyone would understand the model on first glance.

Something like this comes to my mind:
ErrorBoundary.bpmn (5.4 KB)