Merge branch 'hotfix/20240815' into 'master'

hotfix-处理引擎内部异常,包装成自定义Exception抛出异常

See merge request universal/infrastructure/backend/workflow-engine!6
This commit is contained in:
王粒 2024-08-15 09:10:35 +00:00
commit 344ebd149e
4 changed files with 22 additions and 2 deletions

View File

@ -26,6 +26,7 @@ public enum BpmnInstanceRespCode implements IModuleRespCode {
PROCESS_INSTANCE_CANT_START("011", "流程实例不能启动"),
TASK_CANT_COMMENT_INSTANCE_NOT_EXISTS("012", "流程实例【{}】不存在, 不能评论"),
RUNNING_INSTANCE_ONLY_FORECAST("013", "仅运行中的实例可以推测"),
ENGINE_EXEC_EXCEPTION("014", "引擎内部异常"),
;
private final String code;
private final String message;

View File

@ -1,7 +1,11 @@
package cn.axzo.workflow.core.engine.cmd;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.ENGINE_EXEC_EXCEPTION;
/**
* TODO
@ -12,4 +16,19 @@ import org.flowable.common.engine.impl.interceptor.Command;
public abstract class AbstractCommand<T> implements Command<T> {
public abstract String paramToJsonString();
@Override
public T execute(CommandContext commandContext) {
try {
return executeInternal(commandContext);
} catch (WorkflowEngineException e) {
throw e;
} catch (Exception e) {
throw new WorkflowEngineException(ENGINE_EXEC_EXCEPTION);
}
}
public T executeInternal(CommandContext commandContext) {
return null;
}
}

View File

@ -43,7 +43,7 @@ public class CustomApproveTaskAsyncCmd extends AbstractCommand<String> implement
}
@Override
public String execute(CommandContext commandContext) {
public String executeInternal(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration(commandContext);
HistoricTaskInstanceQuery taskQuery =

View File

@ -38,7 +38,7 @@ public class CustomRejectionTaskAsyncCmd extends AbstractCommand<String> impleme
}
@Override
public String execute(CommandContext commandContext) {
public String executeInternal(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration(commandContext);
HistoricTaskInstanceQuery taskQuery =