aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-03-31 14:22:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-03-31 15:38:48 +0200
commitac50467b8a6d043d758dd49954fc6cf8d88ce134 (patch)
tree17a884856d85c46071462b109cfec37ae9aa341f
parent6e40bfcd6da09e80d34c5726ae8d485831498d69 (diff)
Add error code to string returned by what()
-rw-r--r--odb/sqlite/exceptions.cxx12
-rw-r--r--odb/sqlite/exceptions.hxx1
2 files changed, 12 insertions, 1 deletions
diff --git a/odb/sqlite/exceptions.cxx b/odb/sqlite/exceptions.cxx
index 6801665..6bd8bb8 100644
--- a/odb/sqlite/exceptions.cxx
+++ b/odb/sqlite/exceptions.cxx
@@ -3,6 +3,8 @@
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
+#include <sstream>
+
#include <odb/sqlite/exceptions.hxx>
using namespace std;
@@ -24,12 +26,20 @@ namespace odb
database_exception (int e, int ee, const string& m)
: error_ (e), extended_error_ (ee), message_ (m)
{
+ ostringstream ostr;
+ ostr << error_;
+
+ if (error_ != extended_error_)
+ ostr << " (" << extended_error_ << ")";
+
+ ostr << ": " << message_;
+ what_ = ostr.str ();
}
const char* database_exception::
what () const throw ()
{
- return message_.c_str ();
+ return what_.c_str ();
}
//
diff --git a/odb/sqlite/exceptions.hxx b/odb/sqlite/exceptions.hxx
index 5e783a5..cb08e8a 100644
--- a/odb/sqlite/exceptions.hxx
+++ b/odb/sqlite/exceptions.hxx
@@ -52,6 +52,7 @@ namespace odb
int error_;
int extended_error_;
std::string message_;
+ std::string what_;
};
struct LIBODB_SQLITE_EXPORT cli_exception: odb::exception