I am continuously getting the error: TestException.java:8: error: unreported exception Throwable; must be caught or declared to be thrown
throw new ParentException().initCause(new ChildException().initCause(new SQLException()));
Any idea, i know some trivial thing is missing which i am not getting readily to my mind, thanks, don't take source for the face value, i am trying to just refresh my understanding.
import java.sql.SQLException;
public class TestException{
public static void main(String[] args) {
try{
throw new ParentException().initCause(new ChildException().initCause(new SQLException()));
}
catch(ParentException | ChildException | SQLException e){
e.printStackTrace();
try{
Thread.sleep(10*1000);
}
catch(Exception et){
;
}
}
}
}
class ParentException extends Exception{
public ParentException(){
super("Parent Exception is called");
}
}
class ChildException extends Exception{
public ChildException(){
super("Child Exception is called");
}
}