如何使用来自Google Guava的Throwtables.propagateIfInstanceOf()?
try {
someMethodThatCouldThrowAnything();
} catch (IKnowWhatToDoWithThisException e) {
handle(e);
} catch (Throwable t) {
Throwables.propagateIfInstanceOf(t, IOException.class);
Throwables.propagateIfInstanceOf(t, SQLException.class);
throw Throwables.propagate(t);
}
不是很具体。一个真正的程序会是什么样子?我真的不明白Shrewables.propagateIfInstanceOf(Throwable, Class)
, , .我什么时候使用它们?propagate()
propagateIfPossible()