I like the example here :
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
Basically in the source code, main calls function a , which calls function b , which calls ... which calls function e . function e throws a LowLevelException , which is why function c catches a LowLevelException and throws a MidLevelException (terminates the LowLevelException inside the MidLevelException ). The Exception class has a constructor capable of taking in another exception, wrapping it). This calls a function to catch a MidLevelException and throw a HighLevelException , which now wraps the previous two Exception instances.
As noted in other answers, the stack trace is not actually truncated, you see the full stack trace. .. .3 more in my example, because otherwise it will be superfluous. If you want to be redundant and output output lines, .. 3 more can be replaced by
at Junk.b(Junk.java:17) at Junk.a(Junk.java:11) at Junk.main(Junk.java:4)
But there is no need to print these three lines, because they are already implied.
Kevin Wheeler Dec 20 '14 at 2:09 p.m. 2014-12-20 14:09
source share