有没有什么好的函数可以收集字符串中异常的所有原因?该方法printStackTrace()
使用 StackTraces 收集它们:
HighLevelException: MidLevelException: LowLevelException
at Junk.a(Junk.java:13)
at Junk.main(Junk.java:4)
Caused by: MidLevelException: LowLevelException
at Junk.c(Junk.java:23)
at Junk.b(Junk.java:17)
at Junk.a(Junk.java:11)
... 1 more
Caused by: LowLevelException
at Junk.e(Junk.java:30)
at Junk.d(Junk.java:27)
at Junk.c(Junk.java:21)
... 3 more
但我只想要getMessage()
原因:
HighLevelException: MidLevelException: LowLevelException
Caused by: MidLevelException: LowLevelException
Caused by: LowLevelException
我应该编写自己的函数吗?