Error handling for service tasks that uses expression

Hello

I have a multi instance sub process and inside that sub process is a service task that uses an expression to start another process instance.

I’d like to attach a catch mechanism to that service task so it can handle any exceptions from executing the expression. Is this possible? I’d like to avoid creating a custom class and then put try/catch around the method and then throw a BpmnError.

How do I trigger the event sub process from the service task if it uses expression?

Can you upload the models?

What expression is it using exactly?

Generally you can either trigger the error event using the JavaAPI either through JavaScript as a listener or a script task or plane java in the Java Delegate being called by the service task.

This tutorial video explains how error handling works in more detail, you might find it useful.

Hey @Niall…thanks for getting back! The expression I’m using is:

${execution.getProcessEngineServices().getRuntimeService().createProcessInstanceByKey(..).execute()}

If something goes wrong while executing that I’d like to catch it and then do some processing…raise an incident for support to investigate. Just trying to work out how to handle that exception (chances are it might be an engine exception). My service task config looks like:

Thanks for your help.

Why are you expressions, seems like a script or external task would be better suited and it would also make it quite easy to throw the error event.

I could change the send task to use external task but I was hoping to test some of my assertions without needing to configure external tasks hence the use of expressions.