I wrote this little helper method to find the chain of exceptions for a specific exception (either equal or superclass). However, this seems like a solution to a common problem, so he thought it already exists somewhere, perhaps in a library that I already imported. So, any ideas on if / where this could exist?
boolean exceptionSearch(Exception base, Class<?> search) {
Throwable e = base;
do {
if (search.isAssignableFrom(e.getClass())) {
return true;
}
} while ((e = e.getCause()) != null);
return false;
}
source
share