summaryrefslogtreecommitdiff
path: root/odb/mysql/error.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-01-25 18:52:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-01-25 18:52:59 +0300
commit3a160a80c788d81e48acf19a2cf68f29cf125dae (patch)
tree8bf000b3ae959d56367c15aa214a95d24b096905 /odb/mysql/error.cxx
parent35bdfb3e3604527f36f046928324346e8b37b46b (diff)
Turn libodb-mysql repository into package for muti-package repositorylibodb-mysql
Diffstat (limited to 'odb/mysql/error.cxx')
-rw-r--r--odb/mysql/error.cxx76
1 files changed, 0 insertions, 76 deletions
diff --git a/odb/mysql/error.cxx b/odb/mysql/error.cxx
deleted file mode 100644
index 26380ec..0000000
--- a/odb/mysql/error.cxx
+++ /dev/null
@@ -1,76 +0,0 @@
-// file : odb/mysql/error.cxx
-// license : GNU GPL v2; see accompanying LICENSE file
-
-#include <new> // std::bad_alloc
-#include <string>
-
-#include <odb/mysql/mysql.hxx>
-#include <odb/mysql/connection.hxx>
-#include <odb/mysql/exceptions.hxx>
-
-using namespace std;
-
-namespace odb
-{
- namespace mysql
- {
- static void
- translate_error (connection& c,
- unsigned int e,
- const string& sqlstate,
- string msg)
- {
- switch (e)
- {
- case CR_OUT_OF_MEMORY:
- {
- throw bad_alloc ();
- }
- case ER_LOCK_DEADLOCK:
- {
- throw deadlock ();
- }
- case CR_SERVER_LOST:
- case CR_SERVER_GONE_ERROR:
- {
- c.mark_failed ();
- throw connection_lost ();
- }
- case CR_UNKNOWN_ERROR:
- {
- c.mark_failed ();
- }
- // Fall through.
- default:
- {
- // Get rid of a trailing newline if there is one.
- //
- string::size_type n (msg.size ());
- if (n != 0 && msg[n - 1] == '\n')
- msg.resize (n - 1);
-
- throw database_exception (e, sqlstate, msg);
- }
- }
- }
-
- void
- translate_error (connection& c)
- {
- MYSQL* h (c.handle ());
- translate_error (c,
- mysql_errno (h),
- mysql_sqlstate (h),
- mysql_error (h));
- }
-
- void
- translate_error (connection& c, MYSQL_STMT* h)
- {
- translate_error (c,
- mysql_stmt_errno (h),
- mysql_stmt_sqlstate (h),
- mysql_stmt_error (h));
- }
- }
-}