本文整理汇总了Java中java.net.NoRouteToHostException类的典型用法代码示例。如果您正苦于以下问题:Java NoRouteToHostException类的具体用法?Java NoRouteToHostException怎么用?Java NoRouteToHostException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoRouteToHostException类属于java.net包,在下文中一共展示了NoRouteToHostException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNotFoundError
import java.net.NoRouteToHostException; //导入依赖的package包/类
private static String getNotFoundError(CoreException ce) {
IStatus status = ce.getStatus();
Throwable t = status.getException();
if(t instanceof UnknownHostException ||
// XXX maybe a different msg ?
t instanceof SocketTimeoutException ||
t instanceof NoRouteToHostException ||
t instanceof ConnectException)
{
Bugzilla.LOG.log(Level.FINER, null, t);
return NbBundle.getMessage(BugzillaExecutor.class, "MSG_HOST_NOT_FOUND"); // NOI18N
}
String msg = getMessage(ce);
if(msg != null) {
msg = msg.trim().toLowerCase();
if(HTTP_ERROR_NOT_FOUND.equals(msg)) {
Bugzilla.LOG.log(Level.FINER, "returned error message [{0}]", msg); // NOI18N
return NbBundle.getMessage(BugzillaExecutor.class, "MSG_HOST_NOT_FOUND"); // NOI18N
}
}
return null;
}
示例2: testException
import java.net.NoRouteToHostException; //导入依赖的package包/类
@Test
public void testException() throws Throwable {
Exception e =
new NoRouteToHostException("that box caught fire 3 years ago");
ThrowableInformation ti = new ThrowableInformation(e);
Log4Json l4j = new Log4Json();
long timeStamp = Time.now();
String outcome = l4j.toJson(new StringWriter(),
"testException",
timeStamp,
"INFO",
"quoted\"",
"new line\n and {}",
ti)
.toString();
println("testException", outcome);
}
示例3: wrapException
import java.net.NoRouteToHostException; //导入依赖的package包/类
/**
* Take an IOException and a URI, wrap it where possible with
* something that includes the URI
*
* @param dest target URI
* @param operation operation
* @param exception the caught exception.
* @return an exception to throw
*/
public static IOException wrapException(final String dest,
final String operation,
final IOException exception) {
String action = operation + " " + dest;
String xref = null;
if (exception instanceof ConnectException) {
xref = "ConnectionRefused";
} else if (exception instanceof UnknownHostException) {
xref = "UnknownHost";
} else if (exception instanceof SocketTimeoutException) {
xref = "SocketTimeout";
} else if (exception instanceof NoRouteToHostException) {
xref = "NoRouteToHost";
}
String msg = action
+ " failed on exception: "
+ exception;
if (xref != null) {
msg = msg + ";" + see(xref);
}
return wrapWithMessage(exception, msg);
}
示例4: run
import java.net.NoRouteToHostException; //导入依赖的package包/类
public void run() {
try {
startSession();
} catch (IOException ioe) {
int error_code = Proxy.SOCKS_FAILURE;
if (ioe instanceof SocksException)
error_code = ((SocksException) ioe).errCode;
else if (ioe instanceof NoRouteToHostException)
error_code = Proxy.SOCKS_HOST_UNREACHABLE;
else if (ioe instanceof ConnectException)
error_code = Proxy.SOCKS_CONNECTION_REFUSED;
else if (ioe instanceof InterruptedIOException)
error_code = Proxy.SOCKS_TTL_EXPIRE;
if (error_code > Proxy.SOCKS_ADDR_NOT_SUPPORTED
|| error_code < 0) {
error_code = Proxy.SOCKS_FAILURE;
}
sendErrorMessage(error_code);
} finally {
if (auth != null)
auth.endSession();
}
}
示例5: handleException
import java.net.NoRouteToHostException; //导入依赖的package包/类
private void handleException(IOException ioe){
//If we couldn't read the request, return;
if(msg == null) return;
//If have been aborted by other thread
if(mode == ABORT_MODE) return;
//If the request was successfully completed, but exception happened later
if(mode == PIPE_MODE) return;
int error_code = Proxy.SOCKS_FAILURE;
if(ioe instanceof SocksException)
error_code = ((SocksException)ioe).errCode;
else if(ioe instanceof NoRouteToHostException)
error_code = Proxy.SOCKS_HOST_UNREACHABLE;
else if(ioe instanceof ConnectException)
error_code = Proxy.SOCKS_CONNECTION_REFUSED;
else if(ioe instanceof InterruptedIOException)
error_code = Proxy.SOCKS_TTL_EXPIRE;
if(error_code > Proxy.SOCKS_ADDR_NOT_SUPPORTED || error_code < 0){
error_code = Proxy.SOCKS_FAILURE;
}
sendErrorMessage(error_code);
}
示例6: manageSilentlyIOException
import java.net.NoRouteToHostException; //导入依赖的package包/类
public static void manageSilentlyIOException(Exception e){
ClientConfig.setSentryContext(null, null, null, null);
// First we try parsing the exception message to see if it contains the response code
Matcher exMsgStatusCodeMatcher = Pattern.compile("^Server returned HTTP response code: (\\d+)")
.matcher(e.getMessage());
if(exMsgStatusCodeMatcher.find()) {
int statusCode = Integer.parseInt(exMsgStatusCodeMatcher.group(1));
if (statusCode >= 500 && statusCode < 600)
LOG.warn("manageSilentlyIOException", e);
else
LOG.error("manageSilentlyIOException", e);
} else if (e instanceof UnknownHostException
|| e instanceof SocketTimeoutException
|| e instanceof FileNotFoundException
|| e instanceof HttpStatusException
|| e instanceof NoRouteToHostException)
LOG.warn("manageSilentlyIOException", e);
else
LOG.error("manageSilentlyIOException", e);
}
示例7: RemoteSdkException
import java.net.NoRouteToHostException; //导入依赖的package包/类
public RemoteSdkException(String s, Throwable throwable) {
super(s, throwable);
myAuthFailed = false;
Throwable t = throwable;
while (t != null) {
if (t instanceof NoRouteToHostException) {
myCause = t;
myNoRouteToHost = true;
return;
}
t = t.getCause();
}
myNoRouteToHost = false;
myCause = throwable;
}
示例8: handleException
import java.net.NoRouteToHostException; //导入依赖的package包/类
private void handleException(IOException ioe) {
// If we couldn't read the request, return;
if (msg == null)
return;
int error_code = SocksConstants.SOCKS_FAILURE;
if (ioe instanceof SocksException)
error_code = ((SocksException) ioe).getErrorCode();
else if (ioe instanceof NoRouteToHostException)
error_code = SocksConstants.SOCKS_HOST_UNREACHABLE;
else if (ioe instanceof ConnectException)
error_code = SocksConstants.SOCKS_CONNECTION_REFUSED;
else if (ioe instanceof InterruptedIOException)
error_code = SocksConstants.SOCKS_TTL_EXPIRE;
if (error_code > SocksConstants.SOCKS_ADDR_NOT_SUPPORTED
|| error_code < 0) {
error_code = SocksConstants.SOCKS_FAILURE;
}
sendErrorMessage(error_code);
}
示例9: reloadNetworkMapping
import java.net.NoRouteToHostException; //导入依赖的package包/类
public static void reloadNetworkMapping(){
try{
mNetwork = new Network(mContext);
Target network = new Target(mNetwork),
gateway = new Target(mNetwork.getGatewayAddress(), mNetwork.getGatewayHardware()),
device = new Target(mNetwork.getLocalAddress(), mNetwork.getLocalHardware());
gateway.setAlias(mNetwork.getSSID());
device.setAlias(android.os.Build.MODEL);
mTargets.clear();
mTargets.add(network);
mTargets.add(gateway);
mTargets.add(device);
mInitialized = true;
}
catch(NoRouteToHostException nrthe){
// swallow bitch
}
catch(Exception e){
errorLogging(e);
}
}
示例10: sendException
import java.net.NoRouteToHostException; //导入依赖的package包/类
@SuppressLint("DefaultLocale")
public static void sendException(Context c, Exception e, boolean fatal, String additionalData) {
boolean send = true;
if (e instanceof java.net.UnknownHostException || e instanceof NoRouteToHostException) {
fatal = false;
} else if (e instanceof HttpStatusException) {
if (TextUtils.isEmpty(additionalData)) {
additionalData = String.format("%d: %s", ((HttpStatusException) e).getStatusCode(), ((HttpStatusException) e).getUrl());
}
send = (((HttpStatusException) e).getStatusCode() != 503);
} else if (e instanceof SSLException) {
if (!TextUtils.isEmpty(additionalData)) {
additionalData = additionalData + ", ";
} else {
additionalData = "";
}
additionalData = additionalData + getAnalytics().getPsStatus().toString();
}
if (send) {
getAnalytics().sendException(c, e, fatal, additionalData);
}
}
示例11: postNoData
import java.net.NoRouteToHostException; //导入依赖的package包/类
public static Response<?> postNoData(Context context, GHCredentials apiCredentials, String url, Map<String, String> headers) throws NoRouteToHostException,
URISyntaxException, IOException, ClientProtocolException, AuthenticationException, UnsupportedEncodingException {
if (!Utils.isInternetConnectionAvailable(context))
throw new NoRouteToHostException("Network not available");
Log.d(TAG, "Going to perform POST request to " + url);
URI uri = new URI(url);
DefaultHttpClient httpClient = prepareHttpClient(uri, apiCredentials);
HttpPost httpPost = new HttpPost(uri);
setHeaders(httpPost, headers);
// create response object here to measure request duration
Response<String> ret = new Response<String>();
ret.requestStartTime = System.currentTimeMillis();
HttpResponse httpResponse = httpClient.execute(httpPost);
parseResponseHeaders(context, httpResponse, ret);
processStandardHttpResponseCodes(httpResponse);
ret.snapRequestDuration();
writeReponseInfo(ret, context);
return ret;
}
示例12: getConnection
import java.net.NoRouteToHostException; //导入依赖的package包/类
/**
* @throws NoRouteToHostException if the process is terminated.
* @throws UnknownServiceException if the process has no known monitor address.
*/
@Nonnull
public QApiConnection getConnection() throws IOException {
if (monitor == null)
throw new UnknownServiceException("No monitor address known.");
try {
// If this succeeds, then we have exited.
int exitValue = process.exitValue();
connection = null;
throw new NoRouteToHostException("Process terminated with exit code " + exitValue);
} catch (IllegalThreadStateException e) {
}
synchronized (lock) {
if (connection != null)
return connection;
connection = new QApiConnection(monitor);
return connection;
}
}
示例13: SFTPConnection
import java.net.NoRouteToHostException; //导入依赖的package包/类
protected SFTPConnection(ServerEntry server, SSHPool pool) {
this.pool = pool;
try {
JSch jsch = new JSch();
this.session = jsch.getSession(server.getUsername(), server.getServerHostname(), server.getPort());
this.session.setPassword(server.getPassword());
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
this.session.setConfig(config);
this.session.connect();
this.channel = (ChannelSftp) session.openChannel("sftp");
this.channel.connect();
this.channel.cd(server.getRemoteDir());
} catch (Exception e) {
if (e.getCause() instanceof ConnectException || e.getCause() instanceof UnknownHostException || e.getCause() instanceof NoRouteToHostException || (e.getCause() instanceof SocketException && e.getCause().getMessage().equalsIgnoreCase("Network is unreachable"))) {
throw new SFTPOfflineException("No connection to " + server.getServerHostname() + ":" + server.getPort());
} else {
throw new SFTPConnectionException("Unable to connect", e);
}
}
}
示例14: canInfinitelyRetry
import java.net.NoRouteToHostException; //导入依赖的package包/类
@Override
public boolean canInfinitelyRetry(Throwable t){
t=Throwables.getRootCause(t);
t=processPipelineException(t);
if(t instanceof NotServingPartitionException
|| t instanceof WrongPartitionException
|| t instanceof PipelineTooBusy
|| t instanceof RegionBusyException
|| t instanceof NoRouteToHostException
|| t instanceof org.apache.hadoop.hbase.ipc.FailedServerException
|| t instanceof FailedServerException
|| t instanceof ServerNotRunningYetException
|| t instanceof ConnectTimeoutException
|| t instanceof IndexNotSetUpException) return true;
return false;
}
示例15: filterValidationException
import java.net.NoRouteToHostException; //导入依赖的package包/类
public boolean filterValidationException(Exception ex) {
if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex;
if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex;
if (ex instanceof FileNotFoundException ||
ex instanceof MalformedURLException ||
ex instanceof NoRouteToHostException ||
ex instanceof SocketTimeoutException ||
ex instanceof UnknownHostException ||
ex instanceof ConnectException
) {
// do not log problems caused by malformed and/or ignored external resources
return true;
}
if (ex instanceof NullPointerException) {
return true; // workaround for NPE at org.apache.xerces.impl.dtd.XMLDTDProcessor.checkDeclaredElements
}
return false;
}