From c352bdb8b4ee7a636f71a71a301c181942af2d39 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 29 Nov 2011 14:45:51 +0200 Subject: 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. --- odb/oracle/exceptions.cxx | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'odb/oracle/exceptions.cxx') 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 + #include 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 (); } // -- cgit v1.1