Skip to content

Commit 4d83657

Browse files
committed
simplify code
1 parent ef0a221 commit 4d83657

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/main/java/org/htmlunit/html/parser/neko/HtmlUnitNekoHtmlParser.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.io.IOException;
1818
import java.io.InputStream;
1919
import java.io.StringReader;
20-
import java.lang.reflect.InvocationTargetException;
2120
import java.net.URL;
2221
import java.nio.charset.Charset;
2322
import java.util.ArrayList;
@@ -190,27 +189,26 @@ public void parse(final WebClient webClient, final WebResponse webResponse, fina
190189
}
191190

192191
/**
193-
* Extract nested exception within an XNIException (Nekohtml uses reflection and generated
194-
* exceptions are wrapped many times within XNIException and InvocationTargetException)
192+
* Extract nested exception within an XNIException.
195193
*
196194
* @param e the original XNIException
197195
* @return the cause exception
198196
*/
199197
static Throwable extractNestedException(final Throwable e) {
200-
Throwable originalException = e;
201-
Throwable cause = ((XNIException) e).getException();
202-
while (cause != null) {
198+
Throwable originalException;
199+
Throwable cause = e;
200+
do {
203201
originalException = cause;
202+
204203
if (cause instanceof XNIException) {
205-
cause = ((XNIException) cause).getException();
206-
}
207-
else if (cause instanceof InvocationTargetException) {
208204
cause = cause.getCause();
209205
}
210206
else {
211207
cause = null;
212208
}
213209
}
210+
while (cause != null);
211+
214212
return originalException;
215213
}
216214

0 commit comments

Comments
 (0)