Commit 318634741488ea3f07e82436dfc92d5ed4fe0c5f

Authored by zhangmeiyang
1 parent bb29b34e

fix(tax-boot): 记录完整的异常堆栈信息

- 在recordMappingError方法中添加StringWriter和PrintWriter
- 使用printStackTrace将完整堆栈信息写入StringWriter
- 将errorMessage字段设置为完整的堆栈跟踪字符串
- 替换原有的简单消息记录方式
tax-boot/src/main/java/com/diligrp/tax/boot/service/TaxReceiveService.java
@@ -19,6 +19,8 @@ import jakarta.annotation.Resource; @@ -19,6 +19,8 @@ import jakarta.annotation.Resource;
19 import org.springframework.stereotype.Service; 19 import org.springframework.stereotype.Service;
20 import org.springframework.transaction.annotation.Transactional; 20 import org.springframework.transaction.annotation.Transactional;
21 21
  22 +import java.io.PrintWriter;
  23 +import java.io.StringWriter;
22 import java.util.Optional; 24 import java.util.Optional;
23 25
24 /** 26 /**
@@ -86,6 +88,10 @@ public class TaxReceiveService { @@ -86,6 +88,10 @@ public class TaxReceiveService {
86 88
87 @Transactional 89 @Transactional
88 public void recordMappingError(Exception e, MessageContext ctx) { 90 public void recordMappingError(Exception e, MessageContext ctx) {
  91 + // 修改这行以记录完整的堆栈信息
  92 + StringWriter sw = new StringWriter();
  93 + PrintWriter pw = new PrintWriter(sw);
  94 + e.printStackTrace(pw);
89 PipelineMappingErrorDO error = new PipelineMappingErrorDO(); 95 PipelineMappingErrorDO error = new PipelineMappingErrorDO();
90 error.setGroup(ctx.getGroup()); 96 error.setGroup(ctx.getGroup());
91 error.setEntity(ctx.getEntity()); 97 error.setEntity(ctx.getEntity());
@@ -95,7 +101,7 @@ public class TaxReceiveService { @@ -95,7 +101,7 @@ public class TaxReceiveService {
95 error.setPipelineCode(ctx.getPipelineCode()); 101 error.setPipelineCode(ctx.getPipelineCode());
96 error.setOriginData(JsonUtils.toJsonString(ctx.getMsgBody())); 102 error.setOriginData(JsonUtils.toJsonString(ctx.getMsgBody()));
97 error.setState(MappingStateType.SYNC_FAILED.value); 103 error.setState(MappingStateType.SYNC_FAILED.value);
98 - error.setErrorMessage(e.getMessage()); 104 + error.setErrorMessage(sw.toString());
99 taxMappingErrorService.insert(error); 105 taxMappingErrorService.insert(error);
100 } 106 }
101 107