Commit 318634741488ea3f07e82436dfc92d5ed4fe0c5f
1 parent
bb29b34e
fix(tax-boot): 记录完整的异常堆栈信息
- 在recordMappingError方法中添加StringWriter和PrintWriter - 使用printStackTrace将完整堆栈信息写入StringWriter - 将errorMessage字段设置为完整的堆栈跟踪字符串 - 替换原有的简单消息记录方式
Showing
1 changed file
with
7 additions
and
1 deletions
tax-boot/src/main/java/com/diligrp/tax/boot/service/TaxReceiveService.java
| ... | ... | @@ -19,6 +19,8 @@ import jakarta.annotation.Resource; |
| 19 | 19 | import org.springframework.stereotype.Service; |
| 20 | 20 | import org.springframework.transaction.annotation.Transactional; |
| 21 | 21 | |
| 22 | +import java.io.PrintWriter; | |
| 23 | +import java.io.StringWriter; | |
| 22 | 24 | import java.util.Optional; |
| 23 | 25 | |
| 24 | 26 | /** |
| ... | ... | @@ -86,6 +88,10 @@ public class TaxReceiveService { |
| 86 | 88 | |
| 87 | 89 | @Transactional |
| 88 | 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 | 95 | PipelineMappingErrorDO error = new PipelineMappingErrorDO(); |
| 90 | 96 | error.setGroup(ctx.getGroup()); |
| 91 | 97 | error.setEntity(ctx.getEntity()); |
| ... | ... | @@ -95,7 +101,7 @@ public class TaxReceiveService { |
| 95 | 101 | error.setPipelineCode(ctx.getPipelineCode()); |
| 96 | 102 | error.setOriginData(JsonUtils.toJsonString(ctx.getMsgBody())); |
| 97 | 103 | error.setState(MappingStateType.SYNC_FAILED.value); |
| 98 | - error.setErrorMessage(e.getMessage()); | |
| 104 | + error.setErrorMessage(sw.toString()); | |
| 99 | 105 | taxMappingErrorService.insert(error); |
| 100 | 106 | } |
| 101 | 107 | ... | ... |