2015-12-15 11:47:04 -08:00
|
|
|
// exceptions/SameHandler.java
|
2020-10-07 13:35:40 -06:00
|
|
|
// (c)2020 MindView LLC: see Copyright.txt
|
2015-12-15 11:47:04 -08:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|