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