【发布时间】:2011-12-22 09:10:59
【问题描述】:
这是我的场景,我有一个异常列表,其中包含来自不同层次结构的任意异常,下面的代码快照将解释我需要做什么
private List<java.lang.Class> connectionExceptions;
try {
// trying to connect to external module;
} catch(Exception e) {
// Need to compare this exception e with a list of exceptions which I have,
// and the action depends on the results. There may be some other exception
// which are not in the list.
}
那么,我如何比较异常,如果异常在列表中或其他一些中,我需要采取某种操作...
我知道,控制流依赖于异常不是好的做法。但是,我必须这样做。
【问题讨论】:
-
为什么不能使用
List<Exception>?
标签: java exception control-flow