Sfoglia il codice sorgente

Merge pull request #697 from csmith/master

Make LogUtils try some more ctors.
pull/698/head
Greg Holmes 7 anni fa
parent
commit
6a69f328dc
1 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 11
    1
      src/main/java/com/dmdirc/util/LogUtils.java

+ 11
- 1
src/main/java/com/dmdirc/util/LogUtils.java Vedi File

@@ -133,7 +133,17 @@ public final class LogUtils {
133 133
             }
134 134
 
135 135
             if (throwable == null) {
136
-                throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
136
+                try {
137
+                    // Or maybe just a throwable?
138
+                    throwable = clazz.getConstructor(Throwable.class).newInstance(getThrowable(proxy.getCause()));
139
+                } catch (NoSuchMethodException ex) {
140
+                    try {
141
+                        throwable = clazz.getConstructor(String.class).newInstance(proxy.getMessage());
142
+                    } catch (NoSuchMethodException ex2) {
143
+                        // *Shrug*
144
+                        throw new ReflectiveOperationException("Unable to find ctor of " + clazz);
145
+                    }
146
+                }
137 147
             }
138 148
         }
139 149
         throwable.setStackTrace(getStackTraceElements(proxy.getStackTraceElementProxyArray()));

Loading…
Annulla
Salva