Java Code Examples for io.vertx.core.Promise#tryFail()

The following examples show how to use io.vertx.core.Promise#tryFail() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsulServiceImporter.java    From vertx-service-discovery with Apache License 2.0 5 votes vote down vote up
private Handler<Throwable> getErrorHandler(Promise future) {
  return t -> {
    if (future != null) {
      future.tryFail(t);
    } else {
      LOGGER.error(t);
    }
  };
}
 
Example 2
Source File: HonoConnectionImpl.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
private void onLinkEstablishmentTimeout(
        final ProtonLink<?> link,
        final ClientConfigProperties clientConfig,
        final Promise<?> result) {

    if (link.isOpen() && !HonoProtonHelper.isLinkEstablished(link)) {
        log.info("link establishment [peer: {}] timed out after {}ms",
                clientConfig.getHost(), clientConfig.getLinkEstablishmentTimeout());
        link.close();
        // don't free the link here - this may result in an inconsistent session state (see PROTON-2177)
        // instead the link will be freed when the detach from the server is received
        result.tryFail(new ServerErrorException(HttpURLConnection.HTTP_UNAVAILABLE));
    }
}
 
Example 3
Source File: BasicHttpClient.java    From prebid-server-java with Apache License 2.0 4 votes vote down vote up
private static void failResponse(Throwable exception, Promise<HttpClientResponse> promise) {
    promise.tryFail(exception);
}