org.apache.http.conn.HttpHostConnectException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中org.apache.http.conn.HttpHostConnectException.getMessage()方法的一些代码示例,展示了HttpHostConnectException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpHostConnectException.getMessage()方法的具体详情如下:
包路径:org.apache.http.conn.HttpHostConnectException
类名称:HttpHostConnectException
方法名:getMessage

HttpHostConnectException.getMessage介绍

暂无

代码示例

代码示例来源:origin: dreamhead/moco

@Test(expected = ConnectException.class)
public void should_stop_runner_directly() throws IOException {
  runner.run();
  try {
    assertThat(helper.get(root()), is("foo"));
  } catch (HttpHostConnectException e) {
    fail(e.getMessage());
  }
  runner.stop();
  shutdownMoco(SHUTDOWN_PORT, SHUTDOWN_MOCO_KEY);
}

代码示例来源:origin: dreamhead/moco

@Test(expected = HttpHostConnectException.class)
public void should_stop_runner_via_shutdown_task() throws IOException {
  runner.run();
  try {
    assertThat(helper.get(root()), is("foo"));
  } catch (HttpHostConnectException e) {
    fail(e.getMessage());
  }
  ShutdownTask task = new ShutdownTask(SHUTDOWN_MOCO_KEY);
  task.run(new String[]{"-s", Integer.toString(SHUTDOWN_PORT)});
  waitChangeHappens();
  helper.get(root());
}

代码示例来源:origin: dreamhead/moco

@Test(expected = HttpHostConnectException.class)
public void should_shutdown_runner_by_socket() throws IOException {
  runner.run();
  try {
    assertThat(helper.get(root()), is("foo"));
  } catch (HttpHostConnectException e) {
    fail(e.getMessage());
  }
  shutdownMoco(SHUTDOWN_PORT, SHUTDOWN_MOCO_KEY);
  waitChangeHappens();
  helper.get(root());
}

代码示例来源:origin: dreamhead/moco

@Test(expected = HttpHostConnectException.class)
  public void should_shutdown_with_shutdown_port() throws IOException {
    RunnerFactory factory = new RunnerFactory(SHUTDOWN_MOCO_KEY);
    runner = factory.createRunner(httpArgs().withPort(port()).withConfigurationFile("src/test/resources/foo.json").build());
    runner.run();

    try {
      assertThat(helper.get(root()), is("foo"));
    } catch (HttpHostConnectException e) {
      fail(e.getMessage());
    }

    ShutdownRunner shutdownRunner = (ShutdownRunner) runner;
    int port = shutdownRunner.shutdownPort();
    shutdownMoco(port, SHUTDOWN_MOCO_KEY);
    waitChangeHappens();
    helper.get(root());
  }
}

代码示例来源:origin: io.cloudslang.content/cs-http-client

public CloseableHttpResponse execute() {
    CloseableHttpResponse response;
    try {
      response = closeableHttpClient.execute(httpRequestBase, context);
    } catch (SocketTimeoutException ste) {
      throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste);
    } catch (HttpHostConnectException connectEx) {
      throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx);
    } catch (IOException e) {
      throw new RuntimeException("Error while executing http request: " + e.getMessage(), e);
    }
    return response;
  }
}

代码示例来源:origin: io.openscore.content/score-http-client

public CloseableHttpResponse execute() {
    CloseableHttpResponse response;
    try {
      response = closeableHttpClient.execute(httpRequestBase, context);
    } catch (SocketTimeoutException ste) {
      throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste);
    } catch (HttpHostConnectException connectEx) {
      throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx);
    } catch (IOException e) {
      throw new RuntimeException("Error while executing http request: " + e.getMessage(), e);
    }
    return response;
  }
}

代码示例来源:origin: CloudSlang/cs-actions

public CloseableHttpResponse execute() {
    CloseableHttpResponse response;
    try {
      response = closeableHttpClient.execute(httpRequestBase, context);
    } catch (SocketTimeoutException ste) {
      throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste);
    } catch (HttpHostConnectException connectEx) {
      throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx);
    } catch (IOException e) {
      throw new RuntimeException("Error while executing http request: " + e.getMessage(), e);
    }
    return response;
  }
}

代码示例来源:origin: io.cloudslang.content/score-http-client

public CloseableHttpResponse execute() {
    CloseableHttpResponse response;
    try {
      response = closeableHttpClient.execute(httpRequestBase, context);
    } catch (SocketTimeoutException ste) {
      throw new RuntimeException("Socket timeout: " + ste.getMessage(), ste);
    } catch (HttpHostConnectException connectEx) {
      throw new RuntimeException("Connection error: " + connectEx.getMessage(), connectEx);
    } catch (IOException e) {
      throw new RuntimeException("Error while executing http request: " + e.getMessage(), e);
    }
    return response;
  }
}

代码示例来源:origin: elastic/support-diagnostics

protected HttpResponse exec(String url) {
  try {
    HttpGet httpget = new HttpGet(url);
    if (isSecured) {
      return client.execute(httpHost, httpget, getLocalContext(httpHost));
    } else {
      return client.execute(httpHost, httpget);
    }
  } catch (HttpHostConnectException e) {
    logger.log(SystemProperties.DIAG, "Host connection error.", e);
    throw new RuntimeException("Host connection error: " + e.getMessage());
  } catch (Exception e) {
    logger.log(SystemProperties.DIAG, "Query Execution Error", e);
    throw new RuntimeException("Query Execution Error: " + e.getMessage());
  }
}

代码示例来源:origin: jenkinsci/tfs-plugin

log.warning("ERROR: getApiJson: (url=" + url + ") " + e.getMessage());
  return null;
} catch (final Exception e) {

代码示例来源:origin: stackoverflow.com

System.out.println("Host Not Found : "+ e.getMessage())

代码示例来源:origin: org.jenkins-ci.plugins/ec2

} catch (HttpHostConnectException e) {
  log.log(Level.SEVERE, "Can't connect to host", e);
  throw new WinRMConnectException("Can't connect to host: " + e.getMessage(), e);
} catch (IOException e) {
  log.log(Level.SEVERE, "I/O Exception in HTTP POST", e);

代码示例来源:origin: jenkinsci/ec2-plugin

} catch (HttpHostConnectException e) {
  log.log(Level.SEVERE, "Can't connect to host", e);
  throw new WinRMConnectException("Can't connect to host: " + e.getMessage(), e);
} catch (IOException e) {
  log.log(Level.SEVERE, "I/O Exception in HTTP POST", e);

代码示例来源:origin: org.openbaton/sdk

this.bearerToken = "Bearer " + this.token;
} catch (HttpHostConnectException httpHostConnectException) {
 throw new SDKException("Host unreachable: " + httpHostConnectException.getMessage());
} catch (Exception e) {
 throw new SDKException(e);

代码示例来源:origin: edu.cmu.sei.ams.cloudlet/client-lib

throw new CloudletException(e.getMessage(), e);

代码示例来源:origin: no.difi.oxalis/oxalis-as2

protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException {
  Span span = tracer.buildSpan("execute").asChildOf(root).start();
  try (CloseableHttpClient httpClient = httpClientProvider.get()) {
    BasicHttpContext basicHttpContext = new BasicHttpContext();
    basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context());
    CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext);
    span.finish();
    return handleResponse(response);
  } catch (HttpHostConnectException e) {
    span.setTag("exception", e.getMessage());
    throw new OxalisTransmissionException("Receiving server does not seem to be running.",
        transmissionRequest.getEndpoint().getAddress(), e);
  } catch (SSLHandshakeException e) {
    span.setTag("exception", e.getMessage());
    throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.",
        transmissionRequest.getEndpoint().getAddress(), e);
  } catch (IOException e) {
    span.setTag("exception", String.valueOf(e.getMessage()));
    throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e);
  } finally {
    span.finish();
  }
}

代码示例来源:origin: org.smartrplace.apps/smartrplace-util-proposed

/**
 * 
 * @param path
 * @param remotePath
 * @param remoteUser
 * @param remotePw
 * @param serverPortAddress
 * @param am
 * @return upload result or -1: general exception, -2: host not reachable, -3: internet not reachable
 */
public static int sendFile(Path path, String remotePath, String remoteUser, String remotePw, String serverPortAddress, ApplicationManager am) {
  try {
    return upload(path, remotePath, remoteUser, remotePw, serverPortAddress, am);
  } catch (HttpHostConnectException e) {
    am.getLogger().warn(e.getMessage());
    am.getLogger().debug("Exception detail:", e);
    return -2;
  } catch (UnknownHostException| NoRouteToHostException e) {
    am.getLogger().warn(e.getMessage());
    am.getLogger().debug("Exception detail:", e);
    return -3;
  } catch (KeyManagementException | NoSuchAlgorithmException | IOException e) {
    am.getLogger().warn(e.getMessage());
    am.getLogger().debug("Exception detail:", e);
    return -1;
  }
}

代码示例来源:origin: difi/oxalis

protected TransmissionResponse sendHttpRequest(HttpPost httpPost) throws OxalisTransmissionException {
  Span span = tracer.buildSpan("execute").asChildOf(root).start();
  try (CloseableHttpClient httpClient = httpClientProvider.get()) {
    BasicHttpContext basicHttpContext = new BasicHttpContext();
    basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, span.context());
    CloseableHttpResponse response = httpClient.execute(httpPost, basicHttpContext);
    span.finish();
    return handleResponse(response);
  } catch (SocketTimeoutException e) {
    span.setTag("exception", String.valueOf(e.getMessage()));
    throw new OxalisTransmissionException("Receiving server has not sent anything back within SOCKET_TIMEOUT", transmissionRequest.getEndpoint().getAddress(), e);
  } catch (HttpHostConnectException e) {
    span.setTag("exception", e.getMessage());
    throw new OxalisTransmissionException("Receiving server does not seem to be running.",
        transmissionRequest.getEndpoint().getAddress(), e);
  } catch (SSLHandshakeException e) {
    span.setTag("exception", e.getMessage());
    throw new OxalisTransmissionException("Possible invalid SSL Certificate at the other end.",
        transmissionRequest.getEndpoint().getAddress(), e);
  } catch (IOException e) {
    span.setTag("exception", String.valueOf(e.getMessage()));
    throw new OxalisTransmissionException(transmissionRequest.getEndpoint().getAddress(), e);
  } finally {
    span.finish();
  }
}

相关文章