下面列出了io.vertx.core.Promise#tryFail ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Handler<Throwable> getErrorHandler(Promise future) {
return t -> {
if (future != null) {
future.tryFail(t);
} else {
LOGGER.error(t);
}
};
}
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));
}
}
private static void failResponse(Throwable exception, Promise<HttpClientResponse> promise) {
promise.tryFail(exception);
}