title: Dumping Useful Data to Console on Caught Exception
body: <p>I have a <code>CExceptionHandler</code> class that is invoked whenever my application detects a run-time exception.  For example:</p>
  
  <pre><code>if ( val == NULL )
  {
      TRACE(_T("Unexpected NULL in sequence."));
      AfxThrowException( ERROR_INVALID_DATA );
  }
  </code></pre>
  
  <p><code>AfxThrowException</code> is very simple:</p>
  
  <pre><code>void AfxThrowException( DWORD error )
  {
      CExceptionHandler * pException = NULL;
  
      if ( error == 0 )
      {
          error = ::GetLastError();
      }
  
      pException = new CExceptionHandler( error );
  
      TRACE(_T("Warning: throwing CSerialException for error %d\n"), error);
      THROW(pException);
  }
  </code></pre>
  
  <p>This is the member <code>Dump</code> function of <code>CExceptionHandler</code>:</p>
  
  <pre><code>void CExceptionHandler::Dump( CDumpContext &amp; dc ) const
  {
      CObject::Dump(dc);
  
      dc &lt;&lt; "m_dwError = " &lt;&lt; m_dwError;
  }
  </code></pre>
  
  <p>Higher up in my code I have the <code>try</code>/<code>catch</code> statements:</p>
  
  <pre><code>try
  {
      /* My app does stuff where the exception is thrown. */
  }
  catch( CExceptionHandler * ex )
  {
      afxDump &lt;&lt; _T("Dumping exceptional data: ") &lt;&lt; _T("\r\n");
      ex-&gt;Dump( afxDump );
      afxDump &lt;&lt; _T("\r\n");
  }
  </code></pre>
  
  <p>I would like the collected debug information to be dumped to the console.  However, when the PC gets into the <code>catch</code> statement (verified with breakpoint), nothing happens on the console.  I am using Visual Studio 2008 in Debug mode.  Thoughts are appreciated.  Thanks.</p>