Allow subtypes in ExceptionUtil method

This commit is contained in:
nsingh
2017-01-25 16:05:11 -08:00
parent bc38083f4a
commit bc6181d3df

View File

@@ -41,7 +41,7 @@ public class ExceptionUtil {
* @return the throwable instance of the given type, or null if nothing found.
*/
public static Throwable getThrowable(Throwable e, Class<? extends Throwable> toLookFor) {
if (e.getClass().equals(toLookFor)) {
if (e.getClass().isAssignableFrom(toLookFor)) {
return e;
}
@@ -50,7 +50,7 @@ public class ExceptionUtil {
while (parent != null && parent != e) {
cause = parent;
parent = cause.getCause();
if (cause.getClass().equals(toLookFor)) {
if (cause.getClass().isAssignableFrom(toLookFor)) {
return cause;
}
}