Java 类java.net.NoRouteToHostException 实例源码

项目:incubator-netbeans    文件:BugzillaExecutor.java   
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;
}
项目:hadoop-oss    文件:TestLog4Json.java   
@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);
}
项目:hadoop    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:hadoop    文件:TestLog4Json.java   
@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);
}
项目:aliyun-oss-hadoop-fs    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:aliyun-oss-hadoop-fs    文件:TestLog4Json.java   
@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);
}
项目:big-c    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:big-c    文件:TestLog4Json.java   
@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);
}
项目:connectbot    文件:DynamicAcceptThread.java   
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();
    }
}
项目:connectbot    文件:ProxyServer.java   
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);
}
项目:KaellyBot    文件:ExceptionManager.java   
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);

}
项目:intellij-ce-playground    文件:RemoteSdkException.java   
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;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestLog4Json.java   
@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);
}
项目:Tank    文件:SocksProtocolHandler.java   
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);
}
项目:hadoop-plus    文件:TestLog4Json.java   
@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);
}
项目:csploit    文件:System.java   
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);
  }
}
项目:hops    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:hops    文件:TestLog4Json.java   
@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);
}
项目:bVnc    文件:DynamicAcceptThread.java   
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();
    }
}
项目:j2ssh-maverick    文件:ProxyServer.java   
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);
}
项目:anewjkuapp    文件:Analytics.java   
@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);
    }
}
项目:hadoop-TCP    文件:TestLog4Json.java   
@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);
}
项目:ghwatch    文件:RemoteSystemClient.java   
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;
}
项目:hardfs    文件:TestLog4Json.java   
@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);
}
项目:hadoop-on-lustre2    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:hadoop-on-lustre2    文件:TestLog4Json.java   
@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);
}
项目:qemu-java    文件:QEmuProcess.java   
/**
 * @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;
    }
}
项目:sftp-sync    文件:SFTPConnection.java   
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);
        }
    }
}
项目:spliceengine    文件:HPipelineExceptionFactory.java   
@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;
}
项目:consulo    文件:RemoteSdkException.java   
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;
}
项目:sahara-extra    文件:ExceptionDiags.java   
/**
 * 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);
}
项目:consulo-xml    文件:ErrorReporter.java   
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;
}
项目:voldemort    文件:ThresholdFailureDetectorTest.java   
@Test
public void testCatastrophicErrors() throws Exception {
    Node node = Iterables.get(cluster.getNodes(), 8);

    failureDetector.recordException(node,
                                    0,
                                    new UnreachableStoreException("intentionalerror",
                                                                  new ConnectException("intentionalerror")));
    assertEquals(false, failureDetector.isAvailable(node));
    failureDetector.waitForAvailability(node);

    failureDetector.recordException(node,
                                    0,
                                    new UnreachableStoreException("intentionalerror",
                                                                  new UnknownHostException("intentionalerror")));
    assertEquals(false, failureDetector.isAvailable(node));
    failureDetector.waitForAvailability(node);

    failureDetector.recordException(node,
                                    0,
                                    new UnreachableStoreException("intentionalerror",
                                                                  new NoRouteToHostException("intentionalerror")));
    assertEquals(false, failureDetector.isAvailable(node));
    failureDetector.waitForAvailability(node);
}
项目:hadoop-oss    文件:TestLog4Json.java   
@Test
public void testNestedException() throws Throwable {
  Exception e =
      new NoRouteToHostException("that box caught fire 3 years ago");
  Exception ioe = new IOException("Datacenter problems", e);
  ThrowableInformation ti = new ThrowableInformation(ioe);
  Log4Json l4j = new Log4Json();
  long timeStamp = Time.now();
  String outcome = l4j.toJson(new StringWriter(),
      "testNestedException",
      timeStamp,
      "INFO",
      "quoted\"",
      "new line\n and {}",
      ti)
      .toString();
  println("testNestedException", outcome);
  ContainerNode rootNode = Log4Json.parse(outcome);
  assertEntryEquals(rootNode, Log4Json.LEVEL, "INFO");
  assertEntryEquals(rootNode, Log4Json.NAME, "testNestedException");
  assertEntryEquals(rootNode, Log4Json.TIME, timeStamp);
  assertEntryEquals(rootNode, Log4Json.EXCEPTION_CLASS,
      ioe.getClass().getName());
  JsonNode node = assertNodeContains(rootNode, Log4Json.STACK);
  assertTrue("Not an array: " + node, node.isArray());
  node = assertNodeContains(rootNode, Log4Json.DATE);
  assertTrue("Not a string: " + node, node.isTextual());
  //rather than try and make assertions about the format of the text
  //message equalling another ISO date, this test asserts that the hypen
  //and colon characters are in the string.
  String dateText = node.getTextValue();
  assertTrue("No '-' in " + dateText, dateText.contains("-"));
  assertTrue("No '-' in " + dateText, dateText.contains(":"));

}
项目:Readhub-Android    文件:ErrorResult.java   
public static ErrorResult build(@NonNull Throwable t) {
    ErrorResult errorResult = new ErrorResult();
    if (t instanceof UnknownHostException || t instanceof ConnectException) {
        errorResult.setMessage("网络无法连接");
    } else if (t instanceof NoRouteToHostException) {
        errorResult.setMessage("无法访问网络");
    } else if (t instanceof SocketTimeoutException) {
        errorResult.setMessage("网络访问超时");
    } else if (t instanceof JsonSyntaxException) {
        errorResult.setMessage("响应数据格式错误");
    } else {
        errorResult.setMessage("未知错误:" + t.getLocalizedMessage());
    }
    return errorResult;
}
项目:T0rlib4Android    文件:ProxyServer.java   
private void handleException(final 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 = SocksProxyBase.SOCKS_FAILURE;

    if (ioe instanceof SocksException) {
        error_code = ((SocksException) ioe).errCode;
    } else if (ioe instanceof NoRouteToHostException) {
        error_code = SocksProxyBase.SOCKS_HOST_UNREACHABLE;
    } else if (ioe instanceof ConnectException) {
        error_code = SocksProxyBase.SOCKS_CONNECTION_REFUSED;
    } else if (ioe instanceof InterruptedIOException) {
        error_code = SocksProxyBase.SOCKS_TTL_EXPIRE;
    }

    if ((error_code > SocksProxyBase.SOCKS_ADDR_NOT_SUPPORTED)
            || (error_code < 0)) {
        error_code = SocksProxyBase.SOCKS_FAILURE;
    }

    sendErrorMessage(error_code);
}
项目:hadoop    文件:ServerProxy.java   
protected static RetryPolicy createRetryPolicy(Configuration conf,
    String maxWaitTimeStr, long defMaxWaitTime,
    String connectRetryIntervalStr, long defRetryInterval) {
  long maxWaitTime = conf.getLong(maxWaitTimeStr, defMaxWaitTime);
  long retryIntervalMS =
      conf.getLong(connectRetryIntervalStr, defRetryInterval);
  if (maxWaitTime == -1) {
    // wait forever.
    return RetryPolicies.RETRY_FOREVER;
  }

  Preconditions.checkArgument(maxWaitTime > 0, "Invalid Configuration. "
      + maxWaitTimeStr + " should be a positive value.");
  Preconditions.checkArgument(retryIntervalMS > 0, "Invalid Configuration. "
      + connectRetryIntervalStr + "should be a positive value.");

  RetryPolicy retryPolicy =
      RetryPolicies.retryUpToMaximumTimeWithFixedSleep(maxWaitTime,
        retryIntervalMS, TimeUnit.MILLISECONDS);

  Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
  exceptionToPolicyMap.put(EOFException.class, retryPolicy);
  exceptionToPolicyMap.put(ConnectException.class, retryPolicy);
  exceptionToPolicyMap.put(NoRouteToHostException.class, retryPolicy);
  exceptionToPolicyMap.put(UnknownHostException.class, retryPolicy);
  exceptionToPolicyMap.put(RetriableException.class, retryPolicy);
  exceptionToPolicyMap.put(SocketException.class, retryPolicy);
  exceptionToPolicyMap.put(NMNotYetReadyException.class, retryPolicy);

  return RetryPolicies.retryByException(RetryPolicies.TRY_ONCE_THEN_FAIL,
    exceptionToPolicyMap);
}
项目:hadoop    文件:RetryPolicies.java   
@Override
public RetryAction shouldRetry(Exception e, int retries,
    int failovers, boolean isIdempotentOrAtMostOnce) throws Exception {
  if (failovers >= maxFailovers) {
    return new RetryAction(RetryAction.RetryDecision.FAIL, 0,
        "failovers (" + failovers + ") exceeded maximum allowed ("
        + maxFailovers + ")");
  }
  if (retries - failovers > maxRetries) {
    return new RetryAction(RetryAction.RetryDecision.FAIL, 0, "retries ("
        + retries + ") exceeded maximum allowed (" + maxRetries + ")");
  }

  if (e instanceof ConnectException ||
      e instanceof NoRouteToHostException ||
      e instanceof UnknownHostException ||
      e instanceof StandbyException ||
      e instanceof ConnectTimeoutException ||
      isWrappedStandbyException(e)) {
    return new RetryAction(RetryAction.RetryDecision.FAILOVER_AND_RETRY,
        getFailoverOrRetrySleepTime(failovers));
  } else if (e instanceof RetriableException
      || getWrappedRetriableException(e) != null) {
    // RetriableException or RetriableException wrapped 
    return new RetryAction(RetryAction.RetryDecision.RETRY,
          getFailoverOrRetrySleepTime(retries));
  } else if (e instanceof SocketException
      || (e instanceof IOException && !(e instanceof RemoteException))) {
    if (isIdempotentOrAtMostOnce) {
      return RetryAction.FAILOVER_AND_RETRY;
    } else {
      return new RetryAction(RetryAction.RetryDecision.FAIL, 0,
          "the invoked method is not idempotent, and unable to determine "
              + "whether it was invoked");
    }
  } else {
      return fallbackPolicy.shouldRetry(e, retries, failovers,
          isIdempotentOrAtMostOnce);
  }
}
项目:hadoop    文件:TestLog4Json.java   
@Test
public void testNestedException() throws Throwable {
  Exception e =
      new NoRouteToHostException("that box caught fire 3 years ago");
  Exception ioe = new IOException("Datacenter problems", e);
  ThrowableInformation ti = new ThrowableInformation(ioe);
  Log4Json l4j = new Log4Json();
  long timeStamp = Time.now();
  String outcome = l4j.toJson(new StringWriter(),
      "testNestedException",
      timeStamp,
      "INFO",
      "quoted\"",
      "new line\n and {}",
      ti)
      .toString();
  println("testNestedException", outcome);
  ContainerNode rootNode = Log4Json.parse(outcome);
  assertEntryEquals(rootNode, Log4Json.LEVEL, "INFO");
  assertEntryEquals(rootNode, Log4Json.NAME, "testNestedException");
  assertEntryEquals(rootNode, Log4Json.TIME, timeStamp);
  assertEntryEquals(rootNode, Log4Json.EXCEPTION_CLASS,
      ioe.getClass().getName());
  JsonNode node = assertNodeContains(rootNode, Log4Json.STACK);
  assertTrue("Not an array: " + node, node.isArray());
  node = assertNodeContains(rootNode, Log4Json.DATE);
  assertTrue("Not a string: " + node, node.isTextual());
  //rather than try and make assertions about the format of the text
  //message equalling another ISO date, this test asserts that the hypen
  //and colon characters are in the string.
  String dateText = node.getTextValue();
  assertTrue("No '-' in " + dateText, dateText.contains("-"));
  assertTrue("No '-' in " + dateText, dateText.contains(":"));

}