|
|
|
|
|
by vips7L
16 days ago
|
|
Wouldn't you lose a little compile time safety a little by returning the interface, like catching Exception? i.e. as types you don't know about get introduced the compiler won't stop bad things from happening: catch (Exception ex) {
switch (ex) {
case SomeException1 se1 -> ..
case SomeException2 se2 -> ..
default -> throw new IllegalStateException(ex); // panic
}
}
|
|
It's true that if you return an open set of things, you'll have to handle cases you didn't explicitly account for.