Skip to content

Commit

Permalink
Merge pull request #697 from csmith/master
Browse files Browse the repository at this point in the history
Make LogUtils try some more ctors.
  • Loading branch information
greboid committed Jul 4, 2016
2 parents 9bb25db + 6c4b7ff commit 6a69f32
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/com/dmdirc/util/LogUtils.java
Expand Up @@ -133,7 +133,17 @@ public static Throwable getThrowable(@Nonnull final IThrowableProxy proxy)
}

if (throwable == null) {
throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
try {
// Or maybe just a throwable?
throwable = clazz.getConstructor(Throwable.class).newInstance(getThrowable(proxy.getCause()));
} catch (NoSuchMethodException ex) {
try {
throwable = clazz.getConstructor(String.class).newInstance(proxy.getMessage());
} catch (NoSuchMethodException ex2) {
// *Shrug*
throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
}
}
}
}
throwable.setStackTrace(getStackTraceElements(proxy.getStackTraceElementProxyArray()));
Expand Down

0 comments on commit 6a69f32

Please sign in to comment.