aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/exceptions.cxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-11-29 14:45:51 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-11-30 11:32:07 +0200
commitc352bdb8b4ee7a636f71a71a301c181942af2d39 (patch)
tree5b7faa4d826a23162a59e241cb800a9f0f7e2db8 /odb/oracle/exceptions.cxx
parent3ed6a781cf4aad7986f805dc8a8e5c487d10a805 (diff)
Improve the Oracle translate_error implementation
The improved implementation scans all the records associated with an error handle. Furthermore, if it is established that the connection to the database has been lost, the connection is marked as such. Additionally, all special exceptions (deadlock, timeout, and connection_lost) are now supported.
Diffstat (limited to 'odb/oracle/exceptions.cxx')
-rw-r--r--odb/oracle/exceptions.cxx34
1 files changed, 30 insertions, 4 deletions
diff --git a/odb/oracle/exceptions.cxx b/odb/oracle/exceptions.cxx
index 903608e..04928f6 100644
--- a/odb/oracle/exceptions.cxx
+++ b/odb/oracle/exceptions.cxx
@@ -3,6 +3,8 @@
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license : ODB NCUEL; see accompanying LICENSE file
+#include <sstream>
+
#include <odb/oracle/exceptions.hxx>
using namespace std;
@@ -15,9 +17,9 @@ namespace odb
// database_exception
//
- database_exception::
- database_exception (int error, const string& message)
- : error_ (error), message_ (message)
+ database_exception::record::
+ record (int e, const string& m)
+ : error_ (e), message_ (m)
{
}
@@ -26,10 +28,34 @@ namespace odb
{
}
+ database_exception::
+ database_exception ()
+ {
+ }
+
+ database_exception::
+ database_exception (int e, const string& m)
+ {
+ append (e, m);
+ }
+
+ void database_exception::
+ append (int e, const string& m)
+ {
+ records_.push_back (record (e, m));
+
+ if (!what_.empty ())
+ what_ += '\n';
+
+ ostringstream ostr;
+ ostr << e << ": " << m;
+ what_ += ostr.str ();
+ }
+
const char* database_exception::
what () const throw ()
{
- return message_.c_str ();
+ return what_.c_str ();
}
//