title: Catch separate exceptions or use instanceof - Java 6
body: <p>Assume that this piece of code is in 20 places and always the same</p>
  
  <pre><code>try {
      // do something
  } catch (FirstException e) {
      // log it
  } catch (SecondException e) {
      // log it
  }
  </code></pre>
  
  <p>Wouldn't be better to use something like this or <code>instanceof</code> is not good solution?</p>
  
  <pre><code>try {
      // do something
  } catch(Exception e) {
      logException(e);
  }
  
  void logException(Exception e) {
      if (e instanceof FirstException) {
          // log it
      } else if (e instanceof SecondException) {
          // log it differently
      } else {
          // do something with other exception 
      }
  }
  </code></pre>
  
  <p>The only thing that I really hate about the solution is catching <code>Exception</code> which is definitelly not the best way... Is there any better way?</p>