/**
* Take an IOException and the address we were trying to connect to
* and return an IOException with the input exception as the cause.
* The new exception provides the stack trace of the place where
* the exception is thrown and some extra diagnostics information.
* If the exception is ConnectException or SocketTimeoutException,
* return a new one of the same type; Otherwise return an IOException.
*
* @param addr target address
* @param exception the relevant exception
* @return an exception to throw
*/
private IOException wrapException(InetSocketAddress addr,
IOException exception) {
if (exception instanceof ConnectException) {
//connection refused; include the host:port in the error
return (ConnectException)new ConnectException(
"Call to " + addr + " failed on connection exception: " + exception)
.initCause(exception);
} else if (exception instanceof SocketTimeoutException) {
return (SocketTimeoutException)new SocketTimeoutException(
"Call to " + addr + " failed on socket timeout exception: "
+ exception).initCause(exception);
} else if (exception instanceof NoRouteToHostException) {
return (NoRouteToHostException)new NoRouteToHostException(
"Call to " + addr + " failed on NoRouteToHostException exception: "
+ exception).initCause(exception);
} else if (exception instanceof PortUnreachableException) {
return (PortUnreachableException)new PortUnreachableException(
"Call to " + addr + " failed on PortUnreachableException exception: "
+ exception).initCause(exception);
} else {
return (IOException)new IOException(
"Call to " + addr + " failed on local exception: " + exception)
.initCause(exception);
}
}
Client.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:RDFS
作者:
评论列表
文章目录