title: Resharper Exception rethrow possibly intended
body: <p>Consider this method (pardon the sad attempt at Chuck Norris humor :) ):</p>
  
  <pre><code>public class ChuckNorrisException : Exception
  {
      public ChuckNorrisException()
      {
      }
  
      public ChuckNorrisException(string message)
          : base(message)
      {
      }
  
      public ChuckNorrisException(string message, Exception cause)
          : base(message, cause)
      {
      }
  
      protected ChuckNorrisException(SerializationInfo info, StreamingContext context)
          : base(info, context)
      {
      }
  }
  
  static void ExceptionTest(double x)
  {
      try
      {
          double y = 10 / x;
          Console.WriteLine("quotient = " + y);
      }
      catch (Exception e)
      {
          e = e is DivideByZeroException ? new ChuckNorrisException("Only Chuck Norris can divide by 0!", e) :
              e;
          throw e;
      }
  }
  </code></pre>
  
  <p>In resharper, I get a warning on the "throw e" line saying "Exception rethrow possibly intended".  But obviously in this case that's not the intention, since e could be wrapped in ChuckNorrisException, and if I just use "throw", that wrapped exception wouldn't get thrown.</p>
  
  <p>I know I can suppress the resharper warning, but then it will be turned off for <em>all</em> scenarios if I'm not mistaken.  I just wondered if anybody else had encountered this.  The only workaround I've found is to make another exception variable (e2, for example), and throw that. That may be the best I can do here. Seems like resharper could detect this issue though and be smart enough to know that if e is modified, then throw e is ok.</p>
  
  <p>Thanks.</p>
  
  <p><strong>[EDIT]</strong>
  Sorry, I forgot a step. Before the throw, I need to log the exception, so I can't just do:</p>
  
  <pre><code>e = e is DivideByZeroException ? new ChuckNorrisException("Only Chuck Norris can divide by 0!", e) :
              e;
  throw e;
  </code></pre>
  
  <p>I have to do:</p>
  
  <pre><code>e = e is DivideByZeroException ? new ChuckNorrisException("Only Chuck Norris can divide by 0!", e) :
              e;
  LogException(e);
  throw e;
  </code></pre>