aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/exceptions.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/mysql/exceptions.cxx')
-rw-r--r--odb/mysql/exceptions.cxx23
1 files changed, 20 insertions, 3 deletions
diff --git a/odb/mysql/exceptions.cxx b/odb/mysql/exceptions.cxx
index 71c61ec..1373874 100644
--- a/odb/mysql/exceptions.cxx
+++ b/odb/mysql/exceptions.cxx
@@ -31,9 +31,7 @@ namespace odb
sqlstate_ = mysql_sqlstate (h);
message_ = mysql_error (h);
- ostringstream ostr;
- ostr << error_ << " (" << sqlstate_ << "): " << message_;
- what_ = ostr.str ();
+ init ();
}
database_exception::
@@ -46,6 +44,25 @@ namespace odb
sqlstate_ = mysql_stmt_sqlstate (h);
message_ = mysql_stmt_error (h);
+ init ();
+ }
+
+ database_exception::
+ database_exception (unsigned int e, const string& s, const string& m)
+ : error_ (e)
+ {
+ if (error_ == CR_OUT_OF_MEMORY)
+ throw bad_alloc ();
+
+ sqlstate_ = s;
+ message_ = m;
+
+ init ();
+ }
+
+ void database_exception::
+ init ()
+ {
ostringstream ostr;
ostr << error_ << " (" << sqlstate_ << "): " << message_;
what_ = ostr.str ();