title: c# "finally" block that only runs on exceptions
body: <p>Edit: I have looked at the answers code: <strong>NONE</strong> of them do what I want (I've checked). It would seem that there is no way to do what I want in native c#. I guess that's not a disaster just a shame given that .NET does support it (see accepted answer).</p>
  <p>Thanks all.</p>
  <hr />
  <p>I have c# code (part of a test framework that will never be run except under a debugger) like this who's point it to avoid actually catching the exception as that makes debugging the code in the unwound part of the stack a royal pain.</p>
  <pre><code>Bool bad = true;
  try
  {
     MightThrow();
     bad = false;
  }
  finally
  {
     if(bad) DoSomeLoggingOnFailure();
  
     //// Does not catch!!!! 
     //// exception continues to unwind stack.
  
     //// Note that re throwing the exception is NOT
     //// the same as not catching it in the first place
  }
  </code></pre>
  <p>is their a better way to do this?</p>
  <blockquote>
  <p>A solution would have to behave exactly like that under the debugger with regards to un-caught exceptions. It would have to result in the only one first chance exception and the debugger breaking at the point that the exception was <em>originally</em> thrown, not in a catch block.</p>
  <p>Specifically I need the debugger on un-caught exceptions to stop a in side MightThrow.</p>
  </blockquote>
  <p>The following doesn't work because it fails to have the debugger break in the correct place</p>
  <pre><code>try { ... } catch { throw; }
  </code></pre>
  <p>And this doesn't work because it loses stack info (and also breaks in the wrong place).</p>
  <pre><code>try { ... } catch(Exception e) { throw e; }
  </code></pre>
  <p>I known that in <a href="http://www.digitalmars.com/d/1.0/" rel="nofollow noreferrer">D</a> I could use a <a href="http://www.digitalmars.com/d/1.0/statement.html#ScopeGuardStatement" rel="nofollow noreferrer"><code>scope(failure)</code></a> block</p>