Reputation:
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()));
}
Upvotes: 0
Views: 1731
Reputation: 3226
I guess some condition like below will be enough
return !(e instanceof RuntimeException || e instanceof Error);
Upvotes: 2