From d816f54e3c5faeeafe397fd737b812c7a5698bd4 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Thu, 12 Oct 2017 15:27:44 -0500 Subject: [PATCH] Poco::Data::MySQL::ConnectionException doesn't set mysql_ernno() to base Exception class #273 --- Data/MySQL/include/Poco/Data/MySQL/MySQLException.h | 2 +- Data/MySQL/src/MySQLException.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h b/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h index 2f929cf6f..082182dae 100644 --- a/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h +++ b/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h @@ -39,7 +39,7 @@ class MySQL_API MySQLException: public Poco::Data::DataException { public: - MySQLException(const std::string& msg); + MySQLException(const std::string& msg, int errCode = 0); /// Creates MySQLException. MySQLException(const MySQLException& exc); diff --git a/Data/MySQL/src/MySQLException.cpp b/Data/MySQL/src/MySQLException.cpp index d3c7d950f..9cee9bbd3 100644 --- a/Data/MySQL/src/MySQLException.cpp +++ b/Data/MySQL/src/MySQLException.cpp @@ -21,12 +21,14 @@ namespace Data { namespace MySQL { -MySQLException::MySQLException(const std::string& msg) : Poco::Data::DataException(std::string("[MySQL]: ") + msg) +MySQLException::MySQLException(const std::string& msg, int errCode) : + Poco::Data::DataException(std::string("[MySQL]: ") + msg, errCode) { } -MySQLException::MySQLException(const MySQLException& exc) : Poco::Data::DataException(exc) +MySQLException::MySQLException(const MySQLException& exc) : + Poco::Data::DataException(exc) { } @@ -48,7 +50,8 @@ ConnectionException::ConnectionException(const std::string& msg) : MySQLExceptio } -ConnectionException::ConnectionException(const std::string& text, MYSQL* h) : MySQLException(compose(text, h)) +ConnectionException::ConnectionException(const std::string& text, MYSQL* h) : + MySQLException(compose(text, h), mysql_errno(h)) { } @@ -101,7 +104,8 @@ StatementException::StatementException(const std::string& msg) : MySQLException( } -StatementException::StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt) : MySQLException(compose(text, h, stmt)) +StatementException::StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt) : + MySQLException(compose(text, h, stmt), mysql_stmt_errno(h)) { }