title: How to get the exception from a cancelled+interrupted callable submitted to an executor?
body: <p>Consider the following code:</p>
  
  <pre><code>ExecutorService executor = Executors.newSingleThreadExecutor();
  final CountDownLatch taskStarted = new CountDownLatch(1);
  Future&lt;String&gt; future = executor.submit( new Callable&lt;String&gt;() {
      @Override
      public synchronized String call() throws Exception {
          try {
              taskStarted.countDown();
              this.wait( 60000 );
              return "foo";                   
          }
          catch( Exception iWantToGetThisExceptionOutside ) {
              iWantToGetThisExceptionOutside.printStackTrace();
              throw iWantToGetThisExceptionOutside;
          }
      }
  });
  assertTrue(taskStarted.await(60, TimeUnit.SECONDS));
  try {
      future.get(500, TimeUnit.MILLISECONDS);
      fail("Timeout expected.");
  } catch (ExecutionException | TimeoutException e) {
      e.printStackTrace();
  }
  future.cancel(true); //mayInterruptIfRunning
  //how to get iWantToGetThisExceptionOutside here?
  </code></pre>
  
  <p>Is there a way to get the <code>iWantToGetThisExceptionOutside</code> in the main thread after cancelling? Do I have to create my own executor?</p>
  
  <p><strong>EDIT</strong>:
  Just to make clear no <code>ExecutionException</code> is thrown, but <code>TimeoutException</code>, which does not contain any cause. The <code>iWantToGetThisExceptionOutside</code> is a normal <code>InterruptedException</code>.</p>
  
  <p><strong>EDIT2</strong>:
  A little clarification: The task is relatively simple. I want to be able to cancel the task if it runs too long. For this I need a get <code>call</code> with timeout, which throws an exception on timeout. Still I would welcome into my log an entry of a stacktrace which shows <strong>WHERE</strong> the task was cancelled. For that I would need this exception outside the <code>Callable</code>.</p>