Lets take this example
public MyClass{
public void myMethod() throws ExceptionC{
try{
//some method calll throwing ExceptionA, ExceptionB
}catch(ExceptionA | ExceptionB e){
throw new ExceptionC(e);
}
}
}
So I bubble up any of ExceptionA or ExceptionB into higher level as ExceptionC. So I am going to use myClass.myMethod() as follows.
try{
MyClass myclass = new MyClass();
myclass.myMethod();
}catch(Exception C){
//I want to find whether ExceptionC happened from ExceptionA or ExceptionB????
}
So as my code comment suggests //I want to find whether ExceptionC happened from ExceptionA or ExceptionB????
Can someone please explain, how can I do that?
(Please don't take the famous checked-exceptions-good-or-bad war into here.)