List of usage examples for com.google.common.util.concurrent Futures catching
@GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class") @CheckReturnValue public static <V, X extends Throwable> ListenableFuture<V> catching(ListenableFuture<? extends V> input, Class<X> exceptionType, Function<? super X, ? extends V> fallback, Executor executor)
From source file:com.salesforce.grpc.contrib.FutureChain.java
/** * @see Futures#catching(ListenableFuture, Class, Function, Executor) *///from w ww . j a v a2 s . c om public <E extends Throwable> FutureChain<T> catching(Class<E> exceptionType, Function<? super E, ? extends T> fallback) { return new FutureChain<>(Futures.catching(future, exceptionType, fallback, executor), executor); }
From source file:com.facebook.buck.core.build.engine.cache.manager.ManifestRuleKeyServiceImpl.java
@Override public ListenableFuture<CacheResult> fetchManifest(final RuleKey manifestKey, final LazyPath downloadedManifest) { String key = toManifestServiceKey(manifestKey); final ListenableFuture<Manifest> future = manifestService.fetchManifest(key); final ListenableFuture<CacheResult> cacheResultFuture = Futures.transform(future, (manifest) -> writeManifestToFile(manifest, downloadedManifest), MoreExecutors.directExecutor()); return Futures.catching(cacheResultFuture, IOException.class, (exception) -> { String msg = String.format("Failed to fetch manifest with error [%s].", exception); LOG.error(exception, msg);/* w ww . ja va 2 s . c o m*/ return CacheResult.error(MANIFEST_SERVICE_SOURCE, ArtifactCacheMode.unknown, msg); }, MoreExecutors.directExecutor()); }