org.vertx.java.core.http.HttpClient.exceptionHandler()方法的使用及代码示例

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

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

HttpClient.exceptionHandler介绍

[英]Set an exception handler
[中]设置异常处理程序

代码示例

代码示例来源:origin: com.englishtown/vertx-mod-when

protected <T> HttpClient createClient(URI url, final Deferred<T> d) {
  if (url == null) throw new IllegalArgumentException("url is null");
  if (!url.isAbsolute()) throw new IllegalArgumentException("url must be absolute");
  int port = (url.getPort() > 0) ? url.getPort() : 80;
  return vertx.createHttpClient()
      .setHost(url.getHost())
      .setPort(port)
      .setConnectTimeout(CONNECT_TIMEOUT)
      .exceptionHandler(t -> d.reject(t));
}

代码示例来源:origin: vert-x/mod-lang-php

/**
 * Sets the client exception handler.
 */
public HttpClient exceptionHandler(Env env, Value handler) {
 PhpTypes.assertCallable(env, handler, "Argument to Vertx\\Http\\HttpClient::exceptionHandler() must be callable.");
 client.exceptionHandler(HandlerFactory.createExceptionHandler(env, handler));
 return this;
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: io.fastjson/etcd-client

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: io.vertx/vertx-platform

protected HttpClient createClient(String scheme, String host, int port) {
 if (client != null) {
  throw new IllegalStateException("Client already created");
 }
 client = vertx.createHttpClient();
 client.setKeepAlive(false); // Not all servers will allow keep alive connections
 if (proxyHost != null) {
  client.setHost(proxyHost);
  if (proxyPort != 80) {
   client.setPort(proxyPort);
  } else {
   client.setPort(80);
  }
 } else {
  client.setHost(host);
  client.setPort(port);
 }
 if (scheme.equals("https")) {
  client.setSSL(true);
 }
 client.exceptionHandler(new Handler<Throwable>() {
  public void handle(Throwable t) {
   end(false);
  }
 });
 return client;
}

代码示例来源:origin: org.vert-x/vertx-platform

client.setPort(repoPort);
client.exceptionHandler(new Handler<Exception>() {
 public void handle(Exception e) {
  log.error("Unable to connect to repository");

代码示例来源:origin: jboss-fuse/fabric8

final HttpClient finalClient = client;
client.exceptionHandler(new Handler<Throwable>() {
  @Override
  public void handle(Throwable throwable) {

相关文章