title: General Exception Handling in C#
body: <p>I'm running some code through FxCop and am currently looking at clearing all of the non-breaking violations.  </p>
  
  <p>The code itself has a few instances of try/catch blocks which just catch general exceptions;</p>
  
  <pre><code>try
  {
      // Some code in here that could throw an exception
  }
  catch(Exception ex)
  {
      // Exception Thrown ... sort it out!
  }
  </code></pre>
  
  <p>Now we all know this is is bad practice but I thought I knew how to do it properly - but FxCop has other ideas!  </p>
  
  <p>Suppose that the code in the try block could throw an IO Exception - and only an IO exception. There should be nothing wrong with doing this:</p>
  
  <pre><code>try
  {
      // Code in here that can only throw an IOException
  }
  catch (System.IO.IOException ioExp)
  {
      // Handle the IO exception or throw it
  }
  catch (System.Exception ex)
  {
      // Catch otherwise unhandled exception
  }
  </code></pre>
  
  <p>But FxCop disagrees with me ... it still flags this as a violation because I'm catching <code>System.Exception</code>.  </p>
  
  <p>Is this really bad practice or should/can I safely ignore this violation?</p>