#538 prevent destructors from throwing exceptions

This commit is contained in:
Guenter Obiltschnig 2014-09-19 10:13:03 +02:00
parent 5a14f72508
commit 85fd968a1e
11 changed files with 100 additions and 24 deletions

View File

@ -84,9 +84,16 @@ struct MySQL_API MySQLConnectorRegistrator
~MySQLConnectorRegistrator()
/// Calls Poco::Data::MySQL::unregisterConnector();
{
try
{
Poco::Data::MySQL::Connector::unregisterConnector();
}
catch (...)
{
poco_unexpected();
}
}
};

View File

@ -95,9 +95,16 @@ struct ODBC_API ODBCConnectorRegistrator
~ODBCConnectorRegistrator()
/// Calls Poco::Data::ODBC::unregisterConnector();
{
try
{
Poco::Data::ODBC::Connector::unregisterConnector();
}
catch (...)
{
poco_unexpected();
}
}
};

View File

@ -57,6 +57,8 @@ public:
~Handle()
/// Destroys the Handle.
{
try
{
#if defined(_DEBUG)
SQLRETURN rc =
#endif
@ -65,6 +67,11 @@ public:
// leak resources. So, we throw here in debug mode if things go bad.
poco_assert_dbg (!Utility::isError(rc));
}
catch (...)
{
poco_unexpected();
}
}
operator const H& () const
/// Const conversion operator into reference to native type.

View File

@ -39,6 +39,8 @@ ConnectionHandle::ConnectionHandle(EnvironmentHandle* pEnvironment):
ConnectionHandle::~ConnectionHandle()
{
try
{
SQLDisconnect(_hdbc);
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_DBC, _hdbc);
@ -47,6 +49,11 @@ ConnectionHandle::~ConnectionHandle()
poco_assert (!Utility::isError(rc));
}
catch (...)
{
poco_unexpected();
}
}
} } } // namespace Poco::Data::ODBC

View File

@ -40,10 +40,17 @@ EnvironmentHandle::EnvironmentHandle(): _henv(SQL_NULL_HENV)
EnvironmentHandle::~EnvironmentHandle()
{
try
{
SQLRETURN rc = SQLFreeHandle(SQL_HANDLE_ENV, _henv);
poco_assert (!Utility::isError(rc));
}
catch (...)
{
poco_unexpected();
}
}
} } } // namespace Poco::Data::ODBC

View File

@ -51,9 +51,16 @@ Preparator::Preparator(const Preparator& other):
Preparator::~Preparator()
{
try
{
freeMemory();
}
catch (...)
{
poco_unexpected();
}
}
void Preparator::freeMemory() const

View File

@ -69,6 +69,8 @@ SessionImpl::SessionImpl(const std::string& connect,
SessionImpl::~SessionImpl()
{
try
{
if (isTransaction() && !getFeature("autoCommit"))
{
@ -76,8 +78,12 @@ SessionImpl::~SessionImpl()
catch (...) { }
}
try { close(); }
catch (...) { }
close();
}
catch (...)
{
poco_unexpected();
}
}

View File

@ -103,9 +103,16 @@ struct SQLite_API SQLiteConnectorRegistrator
~SQLiteConnectorRegistrator()
/// Calls Poco::Data::SQLite::unregisterConnector();
{
try
{
Poco::Data::SQLite::Connector::unregisterConnector();
}
catch (...)
{
poco_unexpected();
}
}
};

View File

@ -44,9 +44,16 @@ Notifier::Notifier(const Session& session, const Any& value, EnabledEventType en
Notifier::~Notifier()
{
try
{
disableAll();
}
catch (...)
{
poco_unexpected();
}
}
bool Notifier::enableUpdate()

View File

@ -51,9 +51,16 @@ SQLiteStatementImpl::SQLiteStatementImpl(Poco::Data::SessionImpl& rSession, sqli
SQLiteStatementImpl::~SQLiteStatementImpl()
{
try
{
clear();
}
catch (...)
{
poco_unexpected();
}
}
void SQLiteStatementImpl::compileImpl()

View File

@ -56,9 +56,16 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
SessionImpl::~SessionImpl()
{
try
{
close();
}
catch (...)
{
poco_unexpected();
}
}
Poco::Data::StatementImpl* SessionImpl::createStatementImpl()