posted 8 years ago
This is the code for chained exeption. The order is different. As you can see, method 3, method 2, method 1 comparing to method 1, method 2, and method 3.
RESULT OF CHAINED EXCEPTION:
java.lang.Exception: Exception thrown in method1
at UsingChainedExceptions.method1(UsingChainedExceptions.java:27)
at UsingChainedExceptions.main(UsingChainedExceptions.java:10)
Caused by: java.lang.Exception: Exception thrown in method2
at UsingChainedExceptions.method2(UsingChainedExceptions.java:40)
at UsingChainedExceptions.method1(UsingChainedExceptions.java:23)
... 1 more
Caused by: java.lang.Exception: Exception thrown in method3
at UsingChainedExceptions.method3(UsingChainedExceptions.java:47)
at UsingChainedExceptions.method2(UsingChainedExceptions.java:36)
... 2 more
FOLLOWING IS THE CODE FOR STACK UNWINDING.
java.lang.Exception: Exception thrown in method3
at UsingExceptions.method3(UsingExceptions.java:49)
at UsingExceptions.method2(UsingExceptions.java:43)
at UsingExceptions.method1(UsingExceptions.java:37)
at UsingExceptions.main(UsingExceptions.java:10)