aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/database.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/database.cxx
parenta534bbdabe677b67687c9d0093cba4a800b6b766 (diff)
Factor out MySQL error to exception translation into separate function
Diffstat (limited to 'odb/mysql/database.cxx')
-rw-r--r--odb/mysql/database.cxx12
1 files changed, 3 insertions, 9 deletions
diff --git a/odb/mysql/database.cxx b/odb/mysql/database.cxx
index da19ab5..72b18d8 100644
--- a/odb/mysql/database.cxx
+++ b/odb/mysql/database.cxx
@@ -10,6 +10,7 @@
#include <odb/mysql/transaction.hxx>
#include <odb/mysql/connection.hxx>
#include <odb/mysql/connection-factory.hxx>
+#include <odb/mysql/error.hxx>
#include <odb/mysql/exceptions.hxx>
#include <odb/mysql/details/options.hxx>
@@ -220,14 +221,7 @@ namespace odb
MYSQL* h (c.handle ());
if (mysql_real_query (h, s, static_cast<unsigned long> (n)))
- {
- unsigned int e (mysql_errno (h));
-
- if (e == ER_LOCK_DEADLOCK)
- throw deadlock ();
- else
- throw database_exception (h);
- }
+ translate_error (c);
// Get the affected row count, if any. If the statement has a result
// set (e.g., SELECT), we first need to call mysql_store_result().
@@ -244,7 +238,7 @@ namespace odb
mysql_free_result (rs);
}
else
- throw database_exception (h);
+ translate_error (c);
}
return r;