diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java new file mode 100644 index 00000000000..823ada1cd1e --- /dev/null +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jbpm.workflow.instance.impl; + +public class MessageException extends IllegalArgumentException { + private static final long serialVersionUID = 1L; + + public MessageException(String message) { + super(message); + } +} diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java index d5b9c5e3483..cce8bfd6ae3 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java @@ -1164,7 +1164,7 @@ public void setErrorState(NodeInstance nodeInstanceInError, Exception e) { this.nodeInstanceIdInError = nodeInstanceInError.getId(); this.errorCause = Optional.of(e); Throwable rootException = getRootException(e); - this.errorMessage = rootException.getMessage() == null ? rootException.getClass().getCanonicalName() : rootException.getMessage(); + this.errorMessage = rootException instanceof MessageException ? rootException.getMessage() : rootException.getClass().getCanonicalName() + " - " + rootException.getMessage(); setState(STATE_ERROR); logger.error("Unexpected error while executing node {} in process instance {}", nodeInstanceInError.getNode().getName(), this.getStringId(), e); ((InternalProcessRuntime) getKnowledgeRuntime().getProcessRuntime()).getProcessEventSupport().fireOnError(this, nodeInstanceInError, getKnowledgeRuntime(), e); diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/actions/ErrorExpressionAction.java b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/actions/ErrorExpressionAction.java index 33926e40439..efbbe4854d6 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/actions/ErrorExpressionAction.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-runtime/src/main/java/org/kie/kogito/serverless/workflow/actions/ErrorExpressionAction.java @@ -20,6 +20,7 @@ import org.jbpm.process.instance.ProcessInstance; import org.jbpm.workflow.instance.NodeInstance; +import org.jbpm.workflow.instance.impl.MessageException; import org.kie.kogito.internal.process.runtime.KogitoProcessContext; import com.fasterxml.jackson.databind.JsonNode; @@ -44,7 +45,7 @@ public void execute(KogitoProcessContext context) throws Exception { } } - private void setError(KogitoProcessContext context, String error) { - ((ProcessInstance) context.getProcessInstance()).setErrorState((NodeInstance) context.getNodeInstance(), new IllegalArgumentException(error)); + private void setError(KogitoProcessContext context, String message) { + ((ProcessInstance) context.getProcessInstance()).setErrorState((NodeInstance) context.getNodeInstance(), new MessageException(message)); } }