AnsweredAssumed Answered

How to catch an error from a ServiceTask?

Question asked by zlatan316 on Jul 18, 2014
Latest reply on Jul 23, 2014 by zlatan316
Hello,
I have a Call Activity which contains a Service Task. The service task throws an Exception within the execute method as below:

//Checking if report returns NULL
if(valueString.contains("Nothing")) {
   System.out.println("Null coming through: " + valueString);
   execution.setVariable("valueVar", 0);
   throw new Exception("BPMNNullError");
}
else {
   execution.setVariable("valueVar", valueString);
}


The Service Task in my diagram is using an ErrorBoundaryEvent as below::
http://s28.postimg.org/3yhx51fql/bpmnerror.jpg

However it does not follow the path down to the 'Compensate For Lag' Service Task.

Is there a way I can throw an error in Java, and have it get caught by an ErrorEvent attached to the ServiceTask itself as shown? If not, what is the correct way to create it?

Thanks.

Outcomes