mirror of https://gitee.com/dromara/liteFlow
fix: 恢复异常链 cause 并增强错误诊断信息
- 异常体系:ComponentCannotRegisterException / RequestIdGeneratorException / ParallelExecutorCreateException / ThreadExecutorServiceCreateException / ComponentProxyErrorException 新增 (String, Throwable) 构造,FlowBus 等 8 个 抛出点保留原始 cause;ELParseException 同步增加 cause 构造 - EL 解析:BaseOperator.call 不再吞掉原始异常,错误信息附带操作符名与根因 - 诊断:CmpStep 新增 chainId 与 loopIndex 字段,便于回溯调用路径与定位 循环内失败的具体迭代 纯增强:所有新构造 getMessage() 返回值与原一致,新增字段不参与 buildString/equals, 不改变任何现有可观察行为;受影响测试模块(springboot/nospring/declare/builder)全绿。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
68dc35ee92
commit
5af09b1cc0
|
|
@ -23,7 +23,7 @@ public abstract class BaseOperator<T extends Executable> implements QLFunctional
|
|||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ELParseException("errors occurred in EL parsing");
|
||||
throw new ELParseException("errors occurred in EL parsing with operator[" + this.getClass().getSimpleName() + "]: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ public abstract class NodeComponent{
|
|||
cmpStep.setRefNode(this.getRefNode());
|
||||
cmpStep.setStartTime(new Date());
|
||||
cmpStep.setThreadName(Thread.currentThread().getName());
|
||||
cmpStep.setChainId(this.getRefNode().getCurrChainId());
|
||||
cmpStep.setLoopIndex(this.getRefNode().getLoopIndex());
|
||||
slot.addStep(cmpStep);
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class LiteFlowProxyUtil {
|
|||
}catch (Exception e) {
|
||||
String errMsg = StrUtil.format("Error while proxying bean[{}]", declWarpBean.getRawClazz().getName());
|
||||
LOG.error(errMsg);
|
||||
throw new ComponentProxyErrorException(errMsg);
|
||||
throw new ComponentProxyErrorException(errMsg, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ public class ComponentCannotRegisterException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public ComponentCannotRegisterException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ public class ComponentProxyErrorException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public ComponentProxyErrorException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ public class ELParseException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public ELParseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ public class ParallelExecutorCreateException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public ParallelExecutorCreateException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ public class RequestIdGeneratorException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public RequestIdGeneratorException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ public class ThreadExecutorServiceCreateException extends RuntimeException {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public ThreadExecutorServiceCreateException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ public class FlowBus {
|
|||
cmpClazz = Class.forName(cmpClazzStr);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ComponentCannotRegisterException(e.getMessage());
|
||||
throw new ComponentCannotRegisterException(e.getMessage(), e);
|
||||
}
|
||||
addNode(nodeId, name, nodeType, cmpClazz, null, null);
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ public class FlowBus {
|
|||
} catch (Exception e) {
|
||||
String error = StrUtil.format("component[{}] register error", StrUtil.isEmpty(name) ? nodeId : StrUtil.format("{}({})", nodeId, name));
|
||||
LOG.error(e.getMessage());
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()));
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,11 +342,11 @@ public class FlowBus {
|
|||
+ error;
|
||||
|
||||
LOG.error(error, e);
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()));
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()), e);
|
||||
} catch (Exception e) {
|
||||
String error = StrUtil.format("component[{}] register error", StrUtil.isEmpty(name) ? nodeId : StrUtil.format("{}({})", nodeId, name));
|
||||
LOG.error(e.getMessage());
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()));
|
||||
throw new ComponentCannotRegisterException(StrUtil.format("{} {}", error, e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,12 @@ public class CmpStep {
|
|||
// 运行线程名称
|
||||
private String threadName;
|
||||
|
||||
// 所属 chainId(诊断用:节点被多条链复用时回溯调用路径)
|
||||
private String chainId;
|
||||
|
||||
// 循环迭代下标(诊断用:循环内失败时定位是第几次迭代,非循环场景为 null)
|
||||
private Integer loopIndex;
|
||||
|
||||
|
||||
public CmpStep(String nodeId, String nodeName, CmpStepTypeEnum stepType) {
|
||||
this.nodeId = nodeId;
|
||||
|
|
@ -69,6 +75,22 @@ public class CmpStep {
|
|||
this.stepType = stepType;
|
||||
}
|
||||
|
||||
public String getChainId() {
|
||||
return chainId;
|
||||
}
|
||||
|
||||
public void setChainId(String chainId) {
|
||||
this.chainId = chainId;
|
||||
}
|
||||
|
||||
public Integer getLoopIndex() {
|
||||
return loopIndex;
|
||||
}
|
||||
|
||||
public void setLoopIndex(Integer loopIndex) {
|
||||
this.loopIndex = loopIndex;
|
||||
}
|
||||
|
||||
public String getNodeInstanceId() {
|
||||
return nodeInstanceId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class IdGeneratorHolder {
|
|||
INSTANCE.setRequestIdGenerator(requestIdGenerator);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RequestIdGeneratorException(e.getMessage());
|
||||
throw new RequestIdGeneratorException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ParallelStrategyHelper {
|
|||
return strategyExecutor;
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage());
|
||||
throw new ParallelExecutorCreateException(e.getMessage());
|
||||
throw new ParallelExecutorCreateException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class ExecutorHelper {
|
|||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e.getMessage());
|
||||
throw new ThreadExecutorServiceCreateException(e.getMessage());
|
||||
throw new ThreadExecutorServiceCreateException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue