private IOException translateException(HttpURLConnection connection, Exception exception) throws IOException { if (exception instanceof SocketTimeoutException) { //enhance message with timeout values if (exception.getMessage().equals("connect timed out")) { ConnectException cx = new ConnectException("Connect timeout " + connection.getConnectTimeout() + " ms"); cx.setStackTrace(exception.getStackTrace()); throw cx; } else if (exception.getMessage().equals("Read timed out")) { SocketTimeoutException stx = new SocketTimeoutException("Read timeout " + connection.getReadTimeout() + " ms"); stx.setStackTrace(exception.getStackTrace()); throw stx; } else { throw (SocketTimeoutException) exception; } } else if (exception instanceof ConnectException) { //enhance message with url ConnectException ctx = new ConnectException("Connection refused " + config.getUrl()); ctx.setStackTrace(exception.getStackTrace()); throw ctx; } else if (exception instanceof IOException) { throw (IOException) exception; } else { IOException iox = new IOException(exception.getMessage()); iox.setStackTrace(exception.getStackTrace()); throw iox; } }
socketTimeoutException.setStackTrace(e.getStackTrace()); throw responseHandler.handleException(request, socketTimeoutException);
config.getReadTimeoutMillis()); SocketTimeoutException stx = new SocketTimeoutException("Read timeout " + timeout + " ms"); stx.setStackTrace(x.getStackTrace()); throw stx; } else if (x instanceof ConnectException) {
config.getReadTimeoutMillis()); SocketTimeoutException stx = new SocketTimeoutException("Read timeout " + timeout + " ms"); stx.setStackTrace(x.getStackTrace()); throw stx;