title: How to throw a checked exception within CompletableFuture?
body: <p>I used a static method <code>supplyAsync()</code> to get a <code>CompletableFuture</code>, and call its <code>whenComplete()</code> method to deal with the result and exception.</p>
  
  <p><code>whenComplete()</code> accepts a <code>BiConsumer</code> as parameter, and <code>BiConsumer</code>'s second parameter is a <code>Throwable</code>. But I found that I can't throw a checked exception in <code>supply()</code> method. If I did, Idea will show a tip “<em>Unhandled exception: java.lang.exception</em>”.</p>
  
  <pre><code> public static void main(String[] args) {
      Integer i = 0;
  
  
      // unhandled exception
      CompletableFuture&lt;Integer&gt; future = CompletableFuture.supplyAsync(() -&gt; CompletableTest.getInt(i), executorService);
      future.whenComplete((res, e) -&gt;
      {
          System.out.println("res is " + res);
          System.out.println("e is " + e);
      });
  
  }
  
  public static Integer getInt(Integer i) throws Exception {
          Thread.sleep(3000);
          return i + 1;
  }
  </code></pre>
  
  <p>I'm confused, <code>whenComplete()</code> can deal with checked exception, but I can't throw it. </p>
  
  <p>Is it possible to throw a checked exception within <code>CompletableFuture</code>?</p>