OnJava8-Examples/exceptions/SameHandler.java

32 lines
776 B
Java
Raw Normal View History

2015-12-15 11:47:04 -08:00
// exceptions/SameHandler.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
2015-12-15 11:47:04 -08:00
class EBase1 extends Exception {}
class Except1 extends EBase1 {}
class EBase2 extends Exception {}
class Except2 extends EBase2 {}
class EBase3 extends Exception {}
class Except3 extends EBase3 {}
class EBase4 extends Exception {}
class Except4 extends EBase4 {}
public class SameHandler {
void x() throws Except1, Except2, Except3, Except4 {}
void process() {}
void f() {
try {
x();
} catch(Except1 e) {
process();
} catch(Except2 e) {
process();
} catch(Except3 e) {
process();
} catch(Except4 e) {
process();
}
}
}