You should be able to implement the behavior in a Spring bean that uses the current execution to read and update the variables.
You would wire the spring bean named myErrorHandler
with a service task like this
<serviceTask id="checkError"
camunda:expression="#{myErrorHandler.checkError(execution)}" />
The execution
variable is available in the expression per default and points to an instance of DelegateExecution that gives you access to the current process variables.
The implementation of the Spring bean may look as follows:
@Component
public class MyErrorHandler {
/**
* Actual error handler invoked as service
*/
public void checkError(DelegateExecution execution) {
execution.getVariables(); // Map<String, Object> of variables
execution.setVariable("errorCode", 500); // update variable
}
}