Skip to content
Merged

Dev #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import com.codingapi.flow.context.RepositoryHolderContext;
import com.codingapi.flow.event.FlowRecordTodoEvent;
import com.codingapi.flow.event.IFlowEvent;
import com.codingapi.flow.exception.FlowConfigException;
import com.codingapi.flow.exception.FlowStateException;
import com.codingapi.flow.exception.FlowValidationException;
import com.codingapi.flow.node.IFlowNode;
import com.codingapi.flow.record.FlowRecord;
import com.codingapi.flow.script.action.RejectActionScript;
Expand Down Expand Up @@ -76,7 +77,7 @@ public List<FlowRecord> generateRecords(FlowSession flowSession) {
currentNode = flowSession.getWorkflow().getEndNode();
}
if (currentNode == null) {
throw FlowConfigException.currentNodeNotNull();
throw FlowStateException.currentNodeNotNull();
}
flowSession = flowSession.updateSession(currentNode);
return currentNode.generateCurrentRecords(flowSession);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.codingapi.flow.context;

import com.codingapi.flow.domain.DelayTask;
import com.codingapi.flow.exception.FlowConfigException;
import com.codingapi.flow.exception.FlowStateException;
import com.codingapi.flow.gateway.FlowOperatorGateway;
import com.codingapi.flow.operator.IFlowOperator;
import com.codingapi.flow.record.FlowRecord;
Expand Down Expand Up @@ -53,7 +53,7 @@ public boolean isRegistered() {

public void verify() {
if (!isRegistered()) {
throw FlowConfigException.repositoryNotRegistered();
throw FlowStateException.repositoryNotRegistered();
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package com.codingapi.flow.exception;

import com.codingapi.springboot.framework.exception.LocaleMessageException;

/**
* 流程引擎框架异常基类
* <p>
* 所有流程引擎相关的异常都应该继承此类
*
* @since 1.0.0
*/
public abstract class FlowException extends RuntimeException {

private static final long serialVersionUID = 1L;

/**
* 错误码
*/
private final String errorCode;
public abstract class FlowException extends LocaleMessageException {

/**
* 构造函数
Expand All @@ -23,8 +18,7 @@ public abstract class FlowException extends RuntimeException {
* @param message 错误信息
*/
public FlowException(String errorCode, String message) {
super(message);
this.errorCode = errorCode;
super(errorCode,message);
}

/**
Expand All @@ -35,21 +29,7 @@ public FlowException(String errorCode, String message) {
* @param cause 原因
*/
public FlowException(String errorCode, String message, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
super(errorCode,message, cause);
}

/**
* 获取错误码
*
* @return 错误码
*/
public String getErrorCode() {
return errorCode;
}

@Override
public String toString() {
return String.format("[%s] %s", errorCode, getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*/
public class FlowExecutionException extends FlowException {

private static final long serialVersionUID = 1L;

/**
* Constructor
*
Expand Down Expand Up @@ -45,54 +43,6 @@ public static FlowExecutionException scriptExecutionError(String scriptType, Thr
String.format("Script execution error: %s", scriptType), cause);
}

/**
* Node execution error
*
* @param nodeId node ID
* @param cause cause
* @return exception
*/
public static FlowExecutionException nodeExecutionError(String nodeId, Throwable cause) {
return new FlowExecutionException("execution.node.error",
String.format("Node execution error: %s", nodeId), cause);
}

/**
* Action execution error
*
* @param actionId action ID
* @param cause cause
* @return exception
*/
public static FlowExecutionException actionExecutionError(String actionId, Throwable cause) {
return new FlowExecutionException("execution.action.error",
String.format("Action execution error: %s", actionId), cause);
}

/**
* Workflow execution error
*
* @param processId process instance ID
* @param cause cause
* @return exception
*/
public static FlowExecutionException workflowExecutionError(String processId, Throwable cause) {
return new FlowExecutionException("execution.workflow.error",
String.format("Workflow execution error: %s", processId), cause);
}

/**
* Database operation error
*
* @param operation operation type
* @param cause cause
* @return exception
*/
public static FlowExecutionException databaseError(String operation, Throwable cause) {
return new FlowExecutionException("execution.database.error",
String.format("Database operation error: %s", operation), cause);
}

/**
* Router node not found
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
public class FlowNotFoundException extends FlowException {

private static final long serialVersionUID = 1L;

/**
* Constructor
Expand All @@ -23,14 +22,12 @@ public FlowNotFoundException(String code, String message) {
}

/**
* Constructor
* Parallel end node cannot be null
*
* @param code error code
* @param message error message
* @param cause cause
* @return exception
*/
public FlowNotFoundException(String code, String message, Throwable cause) {
super(code, message, cause);
public static FlowNotFoundException parallelEndNodeNotNull() {
return new FlowNotFoundException("notFound.parallel.endNode.required", "Parallel end node cannot be null");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*/
public class FlowPermissionException extends FlowException {

private static final long serialVersionUID = 1L;

/**
* Constructor
*
Expand All @@ -22,38 +20,7 @@ public FlowPermissionException(String code, String message) {
super(code, message);
}

/**
* Constructor
*
* @param code error code
* @param message error message
* @param cause cause
*/
public FlowPermissionException(String code, String message, Throwable cause) {
super(code, message, cause);
}

/**
* Field is read-only
*
* @param fieldName field name
* @return exception
*/
public static FlowPermissionException fieldReadOnly(String fieldName) {
return new FlowPermissionException("permission.field.readOnly",
String.format("Field '%s' is read-only and cannot be modified", fieldName));
}

/**
* Field not found
*
* @param fieldName field name
* @return exception
*/
public static FlowPermissionException fieldNotFound(String fieldName) {
return new FlowPermissionException("permission.field.notFound",
String.format("Field '%s' does not exist", fieldName));
}

/**
* Access denied
Expand All @@ -66,14 +33,4 @@ public static FlowPermissionException accessDenied(String operation) {
String.format("Access denied to operation: %s", operation));
}

/**
* No permission to operate the flow
*
* @param operatorId operator ID
* @return exception
*/
public static FlowPermissionException noPermission(long operatorId) {
return new FlowPermissionException("permission.access.noPermission",
String.format("Operator %d has no permission to access this resource", operatorId));
}
}
Loading