summaryrefslogtreecommitdiff
path: root/libmysqlpp/my-connection.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-29 02:42:43 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-29 06:00:07 +0000
commit97c3d4c1604b525e4522814e34723488c59a83f5 (patch)
treecd9ca0e4b7013d4af1c85c4a677a2cbb12bb9603 /libmysqlpp/my-connection.cpp
parentRemove rebind (diff)
downloadlibdbpp-mysql-97c3d4c1604b525e4522814e34723488c59a83f5.tar.bz2
libdbpp-mysql-97c3d4c1604b525e4522814e34723488c59a83f5.tar.xz
libdbpp-mysql-97c3d4c1604b525e4522814e34723488c59a83f5.zip
Reshuffle and add new exceptions
Diffstat (limited to 'libmysqlpp/my-connection.cpp')
-rw-r--r--libmysqlpp/my-connection.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp
index 3e1aed3..4aa0ab9 100644
--- a/libmysqlpp/my-connection.cpp
+++ b/libmysqlpp/my-connection.cpp
@@ -9,6 +9,11 @@
NAMEDFACTORY("mysql", MySQL::Connection, DB::ConnectionFactory);
+MySQL::ConnectionError::ConnectionError(MYSQL * m) :
+ MySQL::Error(m)
+{
+}
+
class Opts {
public:
Opts() { port = 3306; }
@@ -66,10 +71,10 @@ MySQL::Connection::Connection(const std::string & str) :
}
if (mysql_real_connect(&conn, ~o.server, ~o.user, ~o.password, ~o.database,
o.port, ~o.unix_socket, CLIENT_LOCAL_FILES | CLIENT_MULTI_STATEMENTS) == NULL) {
- throw ConnectionError();
+ throw ConnectionError(&conn);
}
if (mysql_set_character_set(&conn, "utf8")) {
- throw ConnectionError();
+ throw ConnectionError(&conn);
}
}
@@ -83,7 +88,7 @@ MySQL::Connection::finish() const
{
if (txDepth != 0) {
rollbackTx();
- throw Error("Transaction still open");
+ throw DB::TransactionStillOpen();
}
}
@@ -92,7 +97,7 @@ MySQL::Connection::beginTx() const
{
if (txDepth == 0) {
if (mysql_autocommit(&conn, 0)) {
- throw Error(mysql_error(&conn));
+ throw Error(&conn);
}
rolledback = false;
}
@@ -107,7 +112,7 @@ MySQL::Connection::commitTx() const
}
if (--txDepth == 0) {
if (mysql_commit(&conn)) {
- throw Error(mysql_error(&conn));
+ throw Error(&conn);
}
}
return txDepth;
@@ -118,7 +123,7 @@ MySQL::Connection::rollbackTx() const
{
if (--txDepth == 0) {
if (mysql_rollback(&conn)) {
- throw Error(mysql_error(&conn));
+ throw Error(&conn);
}
}
else {
@@ -149,7 +154,7 @@ void
MySQL::Connection::ping() const
{
if (mysql_ping(&conn)) {
- throw Error(mysql_error(&conn));
+ throw Error(&conn);
}
}
@@ -244,7 +249,7 @@ MySQL::Connection::endBulkUpload(const char * msg) const
if (!msg) {
if (ctx->loadReturn) {
ctx.reset();
- throw Error(mysql_error(&conn));
+ throw Error(&conn);
}
}
ctx.reset();