title: How can I clean up my exception handling?
body: <p>I'm looking to clean up the exception mess that is currently the code base I'm working on.</p>
  
  <p>The basic setup is this.</p>
  
  <p>I have an interface that is implemented by a lot of classes that looks like this:</p>
  
  <pre><code>public interface TerminalMessage&lt;E&gt; {
  
     // Override for specific return data type.
     public E send(TerminalStream stream) throws Exception;
  }
  </code></pre>
  
  <p>These classes throw a lot of different exceptions, like IOException, InterruptedException etc.</p>
  
  <p>As it is now, all I do is call getMessage() on the catched exceptions and relay this message to the ui-code.</p>
  
  <p>This is not very nice since I sometimes get bogus messages displayed to the user and I catch unwanted exceptions.</p>
  
  <p>I'm thinking of creating a custom exception class (TerminalException) that would wrap all these kinds of exceptions.</p>
  
  <p>However I'm not sure where to do the wrapping, should the wrapping be done where the exception is first thrown (in the output stream for example) or in every send() method. The former has the advantage of not adding much code, but it makes more sense to me that a stream throws IOException rather than a TerminalException.</p>
  
  <p>The above design also doesn't really solve the sometimes bad messages displayed to the user, so some tip on how to transform the thrown exceptions into something useful to the user would be great!</p>
  
  <p>Thanks!</p>