Como uso Throwables.propagateIfInstanceOf () no Google Guava?
try {
someMethodThatCouldThrowAnything();
} catch (IKnowWhatToDoWithThisException e) {
handle(e);
} catch (Throwable t) {
Throwables.propagateIfInstanceOf(t, IOException.class);
Throwables.propagateIfInstanceOf(t, SQLException.class);
throw Throwables.propagate(t);
}
não é muito concreto. Como seria um programa real? Eu realmente não entendo o propósito dos métodosThrowables.propagateIfInstanceOf(Throwable, Class)
, propagate()
, propagateIfPossible()
. Quando eu os uso?