diff --git a/addons/common/rest-exception-handler/src/main/java/org/kie/kogito/resource/exceptions/BaseExceptionsHandler.java b/addons/common/rest-exception-handler/src/main/java/org/kie/kogito/resource/exceptions/BaseExceptionsHandler.java index cdd3b2ad524..3da864ee7eb 100644 --- a/addons/common/rest-exception-handler/src/main/java/org/kie/kogito/resource/exceptions/BaseExceptionsHandler.java +++ b/addons/common/rest-exception-handler/src/main/java/org/kie/kogito/resource/exceptions/BaseExceptionsHandler.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.function.Function; +import org.kie.kogito.internal.process.runtime.MessageException; import org.kie.kogito.internal.process.workitem.InvalidLifeCyclePhaseException; import org.kie.kogito.internal.process.workitem.InvalidTransitionException; import org.kie.kogito.internal.process.workitem.NotAuthorizedException; @@ -66,6 +67,7 @@ public Function> getResponseGenerator() { } private final FunctionHolder defaultHolder = new FunctionHolder<>(ex -> ex, ex -> BaseExceptionsHandler.this::internalError); + private final FunctionHolder messageFunctionHolder = new FunctionHolder<>(ex -> Collections.singletonMap(MESSAGE, ex.getMessage()), ex -> BaseExceptionsHandler.this::badRequest); protected BaseExceptionsHandler() { mapper = new HashMap<>(); @@ -144,8 +146,8 @@ protected BaseExceptionsHandler() { mapper.put(WorkItemExecutionException.class, new FunctionHolder<>( ex -> Map.of(MESSAGE, ex.getMessage()), ex -> fromErrorCode(((WorkItemExecutionException) ex).getErrorCode()))); - - mapper.put(IllegalArgumentException.class, new FunctionHolder<>(ex -> Collections.singletonMap(MESSAGE, ex.getMessage()), ex -> BaseExceptionsHandler.this::badRequest)); + mapper.put(IllegalArgumentException.class, messageFunctionHolder); + mapper.put(MessageException.class, messageFunctionHolder); } private Function fromErrorCode(String errorCode) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java b/api/kogito-api/src/main/java/org/kie/kogito/internal/process/runtime/MessageException.java similarity index 89% rename from jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java rename to api/kogito-api/src/main/java/org/kie/kogito/internal/process/runtime/MessageException.java index 823ada1cd1e..5aaccdc1cea 100644 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/MessageException.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/internal/process/runtime/MessageException.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jbpm.workflow.instance.impl; +package org.kie.kogito.internal.process.runtime; -public class MessageException extends IllegalArgumentException { +public class MessageException extends RuntimeException { private static final long serialVersionUID = 1L; public MessageException(String 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 cce8bfd6ae3..7ae6edf3fb1 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 @@ -85,6 +85,7 @@ import org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer; import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess; +import org.kie.kogito.internal.process.runtime.MessageException; import org.kie.kogito.jobs.DurationExpirationTime; import org.kie.kogito.jobs.JobsService; import org.kie.kogito.jobs.ProcessInstanceJobDescription; 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 efbbe4854d6..04a22c1e2c1 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,8 +20,8 @@ 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 org.kie.kogito.internal.process.runtime.MessageException; import com.fasterxml.jackson.databind.JsonNode;