Skip to content

Commit 3158fce

Browse files
committed
把 trace:stack 字段值转为 List<String> 返回,避免 Gson 等 JSON 库反序列化报错,并且还更方便浏览
1 parent a25bbc5 commit 3158fce

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractParser.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,16 @@ public M parseResponse(M request) {
630630
res.put("trace:throw", t.getClass().getName());
631631

632632
if (IS_RETURN_STACK_TRACE) {
633-
res.put("trace:stack", t.getStackTrace());
633+
L list = JSON.createJSONArray();
634+
635+
StackTraceElement[] traces = t.getStackTrace();
636+
if (traces != null) { // && traces.length > 0) {
637+
for (StackTraceElement trace : traces) {
638+
list.add(trace == null ? null : trace.toString());
639+
}
640+
}
641+
642+
res.put("trace:stack", list);
634643
}
635644
}
636645
}

0 commit comments

Comments
 (0)