Java CompletableFuture异常处理或传播

时间:2016-10-17 16:03:15

标签: java exception completable-future

我想只处理某种类型的异常并重新抛出它,如果它是另一种类型的异常:

future.exceptionally
(
   (error) ->
   {
      bool wouldBeHandled = ...;
      if (wouldBeHandled)
      {
         Handle();
      }
      else
      {
         throw error; //Want to do this, but can't
         throw new RuntimeException(error); //I don't want to wrap 
      }
   }
);

0 个答案:

没有答案