【发布时间】:2011-02-23 11:44:13
【问题描述】:
try {
someMethodThatCouldThrowAnything();
} catch (IKnowWhatToDoWithThisException e) {
handle(e);
} catch (Throwable t) {
Throwables.propagateIfInstanceOf(t, IOException.class);
Throwables.propagateIfInstanceOf(t, SQLException.class);
throw Throwables.propagate(t);
}
不是很具体。一个真正的程序会是什么样子?我不太明白Throwables.propagateIfInstanceOf(Throwable, Class)、propagate()、propagateIfPossible() 方法的目的。我什么时候使用它们?
【问题讨论】: