2013-10-26 02:50:23 +00:00
|
|
|
|
#pragma once
|
2011-03-03 19:57:34 +00:00
|
|
|
|
|
2013-10-26 02:50:23 +00:00
|
|
|
|
#include <sstream>
|
2017-01-13 21:07:25 +00:00
|
|
|
|
#include <mysqlxx/Types.h>
|
2011-03-03 19:57:34 +00:00
|
|
|
|
#include <Poco/Exception.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace mysqlxx
|
|
|
|
|
{
|
|
|
|
|
|
2011-03-18 20:26:54 +00:00
|
|
|
|
/** Общий класс исключений, которые могут быть выкинуты функциями из библиотеки.
|
|
|
|
|
* Функции code() и errnum() возвращают номер ошибки MySQL. (см. mysqld_error.h)
|
|
|
|
|
*/
|
2011-03-04 20:58:19 +00:00
|
|
|
|
struct Exception : public Poco::Exception
|
|
|
|
|
{
|
|
|
|
|
Exception(const std::string & msg, int code = 0) : Poco::Exception(msg, code) {}
|
2011-07-20 17:30:31 +00:00
|
|
|
|
int errnum() const { return code(); }
|
2011-07-20 17:55:33 +00:00
|
|
|
|
const char * name() const throw() { return "mysqlxx::Exception"; }
|
|
|
|
|
const char * className() const throw() { return "mysqlxx::Exception"; }
|
2011-03-04 20:58:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-03-18 20:26:54 +00:00
|
|
|
|
|
|
|
|
|
/// Не удалось соединиться с сервером.
|
2011-03-04 20:58:19 +00:00
|
|
|
|
struct ConnectionFailed : public Exception
|
|
|
|
|
{
|
|
|
|
|
ConnectionFailed(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
2011-07-20 17:55:33 +00:00
|
|
|
|
const char * name() const throw() { return "mysqlxx::ConnectionFailed"; }
|
|
|
|
|
const char * className() const throw() { return "mysqlxx::ConnectionFailed"; }
|
2011-03-04 20:58:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-03-18 20:26:54 +00:00
|
|
|
|
|
|
|
|
|
/// Запрос содержит ошибку.
|
2011-03-04 20:58:19 +00:00
|
|
|
|
struct BadQuery : public Exception
|
|
|
|
|
{
|
|
|
|
|
BadQuery(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
2011-07-20 17:55:33 +00:00
|
|
|
|
const char * name() const throw() { return "mysqlxx::BadQuery"; }
|
|
|
|
|
const char * className() const throw() { return "mysqlxx::BadQuery"; }
|
2011-03-04 20:58:19 +00:00
|
|
|
|
};
|
2011-03-03 19:57:34 +00:00
|
|
|
|
|
|
|
|
|
|
2011-03-18 20:26:54 +00:00
|
|
|
|
/// Невозможно распарсить значение.
|
|
|
|
|
struct CannotParseValue : public Exception
|
|
|
|
|
{
|
|
|
|
|
CannotParseValue(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
2011-07-20 17:55:33 +00:00
|
|
|
|
const char * name() const throw() { return "mysqlxx::CannotParseValue"; }
|
|
|
|
|
const char * className() const throw() { return "mysqlxx::CannotParseValue"; }
|
2011-03-18 20:26:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2017-01-13 20:37:37 +00:00
|
|
|
|
std::string errorMessage(MYSQL * driver);
|
2011-03-03 19:57:34 +00:00
|
|
|
|
|
2017-01-13 20:37:37 +00:00
|
|
|
|
/// For internal need of library.
|
|
|
|
|
void checkError(MYSQL * driver);
|
|
|
|
|
void onError(MYSQL * driver);
|
2011-03-03 19:57:34 +00:00
|
|
|
|
|
|
|
|
|
}
|