[英]Check if an exception is a checked exception at runtime
Is this the correct way to check if an exception is a checked exception at runtime?这是在运行时检查异常是否为已检查异常的正确方法吗?
public boolean isChecked(final Throwable e) {
return !(RuntimeException.class.isAssignableFrom(e.getClass())
|| Error.class.isAssignableFrom(e.getClass()));
}
I guess some condition like below will be enough我想像下面这样的一些条件就足够了
return !(e instanceof RuntimeException || e instanceof Error);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.