title: Legacy code throws exception in destructor
body: <p>I'm maintaining rather old legacy code. My forerunners pioneerd in exception handling (&lt;2000). The throw and catch logic to handle non-standard behaviour seems to have worked. </p>
  
  <p>They implemented a nice way to throw:</p>
  
  <pre><code>TL_THROW_EXCEPTION(ISQL_MSG_XML_PARSER_ERROR) &lt;&lt; msg; 
  </code></pre>
  
  <p>The TL_THROW_EXCEPTION expands to:</p>
  
  <pre><code>TLThrowTec::CTLThrowExceptionTechnical::ThrowT(__FILE__,__LINE__, 
                                        ISQL_MSG_XML_PARSER_ERROR) &lt;&lt; msg;
  </code></pre>
  
  <p>It creates a TLThrowTec::CTLThrowExceptionTechnical instance on the stack, with shift operations to setup a message string. The destructor creates and throws an exception.</p>
  
  <p>A 2008 entry in stackoverflow explains the state of that year:
  <a href="https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor">throwing exceptions out of a destructor</a> it seems to have worked then.</p>
  
  <p>But now Visual Studio 17 allows to throw, but not to catch anymore. </p>
  
  <p>As the legacy code is part of an overall system it generates log file entries like "unhandled os exception".</p>
  
  <p>I want to get the catch logic back without to much changes in the source. Best would be to come with a #define for TL_THROW_EXCEPTION.</p>
  
  <p>Is there a way to redefine the macro so that the exception is thrown with the message?</p>
  
  <p>If I search for TL_THROW_EXCEPTION this is last line:</p>
  
  <p>Matching lines: 770    Matching files: 217    Total files searched: 3159</p>
  
  <p>I don't like touching all of them.</p>