Skip to content

Commit

Permalink
[Fix apache#3677] Alternative approach
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Sep 24, 2024
1 parent d614e03 commit ff54f84
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}

0 comments on commit ff54f84

Please sign in to comment.