class MyException extends Exception {
MyException() {
super("My Exception");
}
}
class YourException extends Exception {
YourException() {
super("Your Exception");
}
}
class LostException {
public static void main(String[] args) {
try {
someMethod1();
} catch (MyException e) {
System.out.println(e.getMessage());
} catch (YourException e) {
System.out.println(e.getMessage());
}
}
static void someMethod1() throws MyException, YourException {
try {
someMethod2();
} finally {
throw new MyException();
}
}
static void someMethod2() throws YourException {
throw new YourException();
}
}
|