class WorkflowAction {

    public void handleRuntimeException(DelegateExecution execution) {
        StringBuilder wfeExpMsg = new StringBuilder("Runtime error ");
        String runtimeErrorMessage;
        try {
            String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg");
            if (javaExpMsg != null && !javaExpMsg.isEmpty()) {
                wfeExpMsg.append(": ").append(javaExpMsg);
            }
            runtimeErrorMessage = wfeExpMsg.toString();
            logger.error(runtimeErrorMessage);
            execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage);
        } catch (Exception e) {
            logger.error("Runtime error", e);
            // if runtime message was mulformed
            runtimeErrorMessage = "Runtime error";
        }
        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, runtimeErrorMessage);
    }

}