在代码中我遇到了一个InternalError。我希望能够打印出实际错误。
然而,实际错误远远低于堆栈。实际错误是
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Timeout"
Exception in thread "Thread-13" java.lang.InternalError: Should not reach
here
at java.net.HttpConnectSocketImpl.doTunneling(Unknown Source)
at java.net.HttpConnectSocketImpl.doTunnel(Unknown Source)
at java.net.HttpConnectSocketImpl.access$200(Unknown Source)
at java.net.HttpConnectSocketImpl$2.run(Unknown Source)
at java.net.HttpConnectSocketImpl$2.run(Unknown Source)
....
at checker.ui.panels.SystemCheckPanel.run(SystemCheckPanel.java:1058)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
... 15 more
Caused by: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Timeout"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
... 19 more'
如何打印实际错误为504消息。
答案 0 :(得分:0)
try {
blah...
} catch (IOException e) {
Throwable cause = e.getCause();
System.out.println(cause.getMessage());
}