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

This commit is contained in:
yangqicheng 2024-08-15 11:57:49 +08:00
parent a64807017a
commit 694a95d267
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", "流程实例不能启动"), PROCESS_INSTANCE_CANT_START("011", "流程实例不能启动"),
TASK_CANT_COMMENT_INSTANCE_NOT_EXISTS("012", "流程实例【{}】不存在, 不能评论"), TASK_CANT_COMMENT_INSTANCE_NOT_EXISTS("012", "流程实例【{}】不存在, 不能评论"),
RUNNING_INSTANCE_ONLY_FORECAST("013", "仅运行中的实例可以推测"), RUNNING_INSTANCE_ONLY_FORECAST("013", "仅运行中的实例可以推测"),
ENGINE_EXEC_EXCEPTION("014", "引擎内部异常"),
; ;
private final String code; private final String code;
private final String message; private final String message;

View File

@ -1,7 +1,11 @@
package cn.axzo.workflow.core.engine.cmd; 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.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import static cn.axzo.workflow.core.common.code.BpmnInstanceRespCode.ENGINE_EXEC_EXCEPTION;
/** /**
* TODO * TODO
@ -12,4 +16,19 @@ import org.flowable.common.engine.impl.interceptor.Command;
public abstract class AbstractCommand<T> implements Command<T> { public abstract class AbstractCommand<T> implements Command<T> {
public abstract String paramToJsonString(); 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 @Override
public String execute(CommandContext commandContext) { public String executeInternal(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = ProcessEngineConfigurationImpl processEngineConfiguration =
CommandContextUtil.getProcessEngineConfiguration(commandContext); CommandContextUtil.getProcessEngineConfiguration(commandContext);
HistoricTaskInstanceQuery taskQuery = HistoricTaskInstanceQuery taskQuery =

View File

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