if an activity throws a BpmnError, then an error boundary event can be attached to the activity to “catch” it and let the process continue at a specific path. Along with the error event, two data elements are passed: the error code and the error message.
But what if I want to pass more data with the error event? E.g. some complex java object? How would I do that?
My only idea so far has been the following: Just before throwing a BpmnError in the activity’s code, I’d set the data to pass along with the error as a process variable, e.g. via execution.setVariable("myErrorInfo", errorData). Then the steps on the path starting with the error boundary event will be able to access that data via execution.getVariable("myErrorInfo").
throw new BpmnError("boundaryErrorCode", "Message that will turn into variable and will be held by the Error Message Variable value as a process variable");
Here is the result when I check my variables in my process instance.
As per the docs it is only possible to pass a String. I believe such String is meant to indicate a simple reasoning behind the triggering of such error event. Anything else besides a simple String must be set as a process variable as per your recommended approach.