ClickHouse/libs/libmysqlxx/src/Exception.cpp
Orivej Desh 5ec179377a DEVTOOLS-5170 Delete Y_IGNORE markers (#5533)
They have been superseded by a new include resolution configuration that lives
outside clickhouse source tree.
2019-06-05 14:52:39 +03:00

39 lines
755 B
C++

#if __has_include(<mariadb/mysql.h>)
#include <mariadb/mysql.h>
#else
#include <mysql/mysql.h>
#endif
#include <mysqlxx/Exception.h>
namespace mysqlxx
{
std::string errorMessage(MYSQL * driver)
{
std::stringstream res;
res << mysql_error(driver)
<< " (" << (driver->host ? driver->host : "(nullptr)")
<< ":" << driver->port << ")";
return res.str();
}
/// Для внутренних нужд библиотеки.
void checkError(MYSQL * driver)
{
unsigned num = mysql_errno(driver);
if (num)
throw Exception(errorMessage(driver), num);
}
/// Для внутренних нужд библиотеки.
void onError(MYSQL * driver)
{
throw Exception(errorMessage(driver), mysql_errno(driver));
}
}