title: Handling the cause of an ExecutionException
body: <p>Suppose I have a class defining a big block of work to be done, that can produce several checked Exceptions.</p>
  
  <pre><code>class WorkerClass{
     public Output work(Input input) throws InvalidInputException, MiscalculationException {
        ...
     }
  }
  </code></pre>
  
  <p>Now suppose I have a GUI of some sort that can call this class. I use a SwingWorker to delegate the task.</p>
  
  <pre><code>Final Input input = getInput();
  SwingWorker&lt;Output, Void&gt; worker = new SwingWorker&lt;Output, Void&gt;() {
          @Override
          protected Output doInBackground() throws Exception {
              return new WorkerClass().work(input);
          }
  };
  </code></pre>
  
  <p>How can I handle the possible exceptions thrown from the SwingWorker? I want to differentiate between the Exceptions of my worker class (InvalidInputException and MiscalculationException), but the ExecutionException wrapper complicates things. I only want to handle these Exceptions - an OutOfMemoryError should not be caught.</p>
  
  <pre><code>try{
     worker.execute();
     worker.get();
  } catch(InterruptedException e){
     //Not relevant
  } catch(ExecutionException e){
     try{
        throw e.getCause(); //is a Throwable!
     } catch(InvalidInputException e){
        //error handling 1
     } catch(MiscalculationException e){
        //error handling 2
     }
  }
  //Problem: Since a Throwable is thrown, the compiler demands a corresponding catch clause.
  </code></pre>