aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/exceptions.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:45:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:45:36 +0200
commitfcfe083c7a6d12eb4b6b88eea4a5ebbfc4d36995 (patch)
treeba60af2863d425e8be78749558c73910ab2f921d /odb/mysql/exceptions.cxx
parent073918a2f4bff3a6f12cfd722db50e3fb0a6db0d (diff)
Initial implementation
Diffstat (limited to 'odb/mysql/exceptions.cxx')
-rw-r--r--odb/mysql/exceptions.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/odb/mysql/exceptions.cxx b/odb/mysql/exceptions.cxx
new file mode 100644
index 0000000..4ee80fb
--- /dev/null
+++ b/odb/mysql/exceptions.cxx
@@ -0,0 +1,38 @@
+// file : odb/mysql/exceptions.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <sstream>
+
+#include <odb/mysql/exceptions.hxx>
+
+using namespace std;
+
+namespace odb
+{
+ namespace mysql
+ {
+ database_exception::
+ ~database_exception () throw ()
+ {
+ }
+
+ database_exception::
+ database_exception (MYSQL* h)
+ : error_ (mysql_errno (h)),
+ sqlstate_ (mysql_sqlstate (h)),
+ message_ (mysql_error (h))
+ {
+ ostringstream ostr;
+ ostr << error_ << " (" << sqlstate_ << "): " << message_;
+ what_ = ostr.str ();
+ }
+
+ char const* database_exception::
+ what () const throw ()
+ {
+ return what_.c_str ();
+ }
+ }
+}