title: How should I handle exceptions when using SwingWorker?
body: <p>I use SwingWorker in Java 6 to avoid running long-running code on the event dispatch thread.</p>
  
  <p>If the call to get() in my done() method returns an exception, what is an appropriate way of handling the exception?</p>
  
  <p>I'm particularly concerned about possible InterruptedExceptions. The JavaDoc example simply ignores the exception but I've learnt over the years that swallowing exceptions leads to hard-to-debug code. </p>
  
  <p>A sample usage is as follows:</p>
  
  <pre><code>new SwingWorker&lt;String, Void&gt;() {
  
      @Override
      protected String doInBackground() throws Exception {
          // do long-running calculation
          return result;
      }
  
      @Override
      protected void done() {
          try {
              setTextField(get());
          } catch (InterruptedException e) {
              e.printStackTrace();  
          } catch (ExecutionException e) {
              e.printStackTrace();  
          }
      }
  }.execute();
  </code></pre>