[英]Does java completableFuture has method returning CompletionStage<U> to handle exception?
Does java completableFuture have thenCompose method having param with CompletionStage value type to handle exception? java completableFuture 是否有 thenCompose 方法,其参数具有 CompletionStage 值类型来处理异常? like this method:像这样的方法:
public <U> CompletableFuture<U> thenCompose(BiFunction<? super T, Throwable, ? extends CompletionStage<U>> var1)
I want to handle the result and exception and convert the result use a function A returning a completableFuture, just like:我想处理结果和异常并使用 function A 返回 completableFuture 转换结果,就像:
CompletableFuture<V> A(V v,Throwable e);
and function A will call RPC.而function A会调用RPC。 It is a async function.它是一个异步 function。
CompletableFuture.handle(BiFunction<? super T, Throwable, ? extends U> var1) just convert the result, can not combine two completableFuture, can not meet my needs. CompletableFuture.handle(BiFunction<? super T, Throwable, ? extends U> var1) 只是转换结果,不能合并两个completableFuture,不能满足我的需求。
Have you tried to chain thenCompose
with handle
or exceptionally
?您是否尝试过将thenCompose
与handle
或exceptionally
链接起来?
It should meet your needs.它应该满足您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.