Commit 7c22c536 by zhouhaibao

fix(strategy): 优化策略执行中的异常处理

- 修改分支动作执行时的异常信息,从具体分支ID改为通用提示
- 将微信消息变量替换时的日志级别从debug提升到info
- 当未找到变量值时抛出运行时异常而不是仅记录警告
- 简化IMHub API调用失败时的异常信息为统一的发送消息失败提示
1 parent bee87142
......@@ -241,7 +241,7 @@ public class SopStrategyExecutionService {
private void executeBranchActions(SopStrategyBranch branch, Long customerInstanceId, Integer strategyId, Map<String, Object> contextVariables) {
List<SopStrategyAction> actions = branch.getActions();
if (CollUtil.isEmpty(actions)) {
throw new RuntimeException("分支无动作, branchId:" + branch.getId());
throw new RuntimeException("找不到可执行的动作");
}
for (SopStrategyAction action : actions) {
......
......@@ -219,9 +219,9 @@ public class WechatMessageActionExecutor implements SopActionExecutor {
if (variableValue != null) {
String valueStr = String.valueOf(variableValue);
result = result.replace("{{" + variableName + "}}", valueStr);
log.debug("替换变量: {} = {}", variableName, valueStr);
log.info("替换变量: {} = {}", variableName, valueStr);
} else {
log.warn("未找到变量值: {}", variableName);
throw new RuntimeException("消息内容文本变量异常");
}
}
......@@ -299,7 +299,7 @@ public class WechatMessageActionExecutor implements SopActionExecutor {
log.info("IMHub API调用成功, taskType:{}, response:{}", taskType, response);
} catch (Exception e) {
log.error("IMHub API调用失败, taskType:{}, error:{}", taskType, e.getMessage(), e);
throw new RuntimeException("IMHub API调用失败: " + e.getMessage(), e);
throw new RuntimeException("发送消息失败");
}
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!