Fix NASTY C++ PITFALL: Function try blocks implicitly rethrow the exception

https://stackoverflow.com/a/5612508

Function try blocks silently rethrow the exception in ctors/dtors, even
with "catch(...){}". Changed to standard try/catch.

Now also logging exceptions.
This commit is contained in:
Robert Schulze 2023-01-03 20:39:08 +00:00
parent 0dda4921ba
commit 4bdab0d5e8
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A

View File

@ -177,6 +177,7 @@ QueryResultCache::Writer::Writer(std::mutex & mutex_, Cache & cache_, const Key
}
QueryResultCache::Writer::~Writer()
{
try
{
if (skip_insert)
@ -239,8 +240,10 @@ try
LOG_DEBUG(&Poco::Logger::get("QueryResultCache"), "Stored result of query {}", key.queryStringFromAst());
}
}
catch (const std::exception &)
catch (...)
{
tryLogCurrentException(&Poco::Logger::get("QueryResultCache"), __PRETTY_FUNCTION__);
}
}
void QueryResultCache::Writer::buffer(Chunk && partial_query_result)