How to access the error message from BpmnError

Hello there,

a service task in my process can throw a BpmnError:

String errorMessage = “this is an error message”;
String errorCode = “MY-ERROR”;
throw new BpmnError(errorCode, errorMessage);

I need the errorMessage stored in a processVariable so I can pass it to the parent process. How do I achieve this without having to use the execution instance:

execution.setVariable(…)

I would expect when setting the the error message variable in the bpmn, it would automatically fill it with whatever message I pass with the BpmnError but that’s not the case. Setting the error message variable in the bpmn, creates a process variable but it’s of type NULL and has a empty value.

Am I doing something wrong ?
Thank you

myErrorExample.bpmn (3.7 KB)

Hi @logi,

in the modeler, I leave the “Error Message” empty and enter a variable name in “Error Message Variable”. With this variable I can refer to the message content, provided in the delegate, in a following task.

Hope this helps, Ingo