i was reading about Throwable class from https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html but i was not able to understand the chained exception facility. so somebody can please help me in this.
Asked
Active
Viewed 155 times
-1
-
I think above link could be detailed answer your question . – soorapadman Jun 23 '17 at 06:48
1 Answers
3
As Oracle doc says
Chained Exception Facility
It is common for Java code to catch one exception and throw another
And an example here from TutorialsPoint:
public class Main{
public static void main (String args[])throws Exception {
int n = 20, result = 0;
try {
result = n/0;
System.out.println("The result is"+result);
} catch(ArithmeticException ex) {
System.out.println ("Arithmetic exception occoured: "+ex);
try {
throw new NumberFormatException(ex);
} catch(NumberFormatException ex1) {
System.out.println ("Chained exception thrown manually : "+ex1);
}
}
}
}