summaryrefslogtreecommitdiff
path: root/odb/mysql/transaction-impl.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-02-18 17:56:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-02-18 17:56:53 +0200
commit4acabe57939ff37bad0a8aabc5164b6d5add449b (patch)
tree1211cf34b447014671effc59770f06f1cc0e3bb8 /odb/mysql/transaction-impl.cxx
parenta534bbdabe677b67687c9d0093cba4a800b6b766 (diff)
Factor out MySQL error to exception translation into separate function
Diffstat (limited to 'odb/mysql/transaction-impl.cxx')
-rw-r--r--odb/mysql/transaction-impl.cxx20
1 files changed, 7 insertions, 13 deletions
diff --git a/odb/mysql/transaction-impl.cxx b/odb/mysql/transaction-impl.cxx
index 73011b4..b523568 100644
--- a/odb/mysql/transaction-impl.cxx
+++ b/odb/mysql/transaction-impl.cxx
@@ -7,7 +7,7 @@
#include <odb/mysql/database.hxx>
#include <odb/mysql/connection.hxx>
#include <odb/mysql/statement.hxx>
-#include <odb/mysql/exceptions.hxx>
+#include <odb/mysql/error.hxx>
#include <odb/mysql/transaction-impl.hxx>
namespace odb
@@ -18,10 +18,8 @@ namespace odb
transaction_impl (database_type& db)
: odb::transaction_impl (db), connection_ (db.connection ())
{
- MYSQL* h (connection_->handle ());
-
- if (mysql_real_query (h, "begin", 5) != 0)
- throw database_exception (h);
+ if (mysql_real_query (connection_->handle (), "begin", 5) != 0)
+ translate_error (*connection_);
}
transaction_impl::
@@ -35,10 +33,8 @@ namespace odb
if (statement* a = connection_->active ())
a->cancel ();
- MYSQL* h (connection_->handle ());
-
- if (mysql_real_query (h, "commit", 6) != 0)
- throw database_exception (h);
+ if (mysql_real_query (connection_->handle (), "commit", 6) != 0)
+ translate_error (*connection_);
// Release the connection.
//
@@ -51,10 +47,8 @@ namespace odb
if (statement* a = connection_->active ())
a->cancel ();
- MYSQL* h (connection_->handle ());
-
- if (mysql_real_query (h, "rollback", 8) != 0)
- throw database_exception (h);
+ if (mysql_real_query (connection_->handle (), "rollback", 8) != 0)
+ translate_error (*connection_);
// Release the connection.
//