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) {}
|
2017-04-01 07:20:54 +00:00
|
|
|
|
int errnum() const { return code(); }
|
|
|
|
|
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
|
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
|
ConnectionFailed(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
|
|
|
|
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
|
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
|
BadQuery(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
|
|
|
|
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
|
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
|
CannotParseValue(const std::string & msg, int code = 0) : Exception(msg, code) {}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
}
|