diff options
Diffstat (limited to 'libodb-pgsql/odb/pgsql/exceptions.cxx')
-rw-r--r-- | libodb-pgsql/odb/pgsql/exceptions.cxx | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/libodb-pgsql/odb/pgsql/exceptions.cxx b/libodb-pgsql/odb/pgsql/exceptions.cxx new file mode 100644 index 0000000..28e7fc4 --- /dev/null +++ b/libodb-pgsql/odb/pgsql/exceptions.cxx @@ -0,0 +1,79 @@ +// file : odb/pgsql/exceptions.cxx +// license : GNU GPL v2; see accompanying LICENSE file + +#include <sstream> + +#include <odb/pgsql/exceptions.hxx> + +using namespace std; + +namespace odb +{ + namespace pgsql + { + // + // database_exception + // + + database_exception:: + database_exception (const string& message) + : message_ (message), what_ (message) + { + } + + database_exception:: + database_exception (const string& sqlstate, + const string& message) + : sqlstate_ (sqlstate), message_ (message) + { + if (!sqlstate_.empty ()) + what_ = sqlstate_ + ": " + message_; + else + what_ = message_; + } + + database_exception:: + ~database_exception () ODB_NOTHROW_NOEXCEPT + { + } + + const char* database_exception:: + what () const ODB_NOTHROW_NOEXCEPT + { + return what_.c_str (); + } + + database_exception* database_exception:: + clone () const + { + return new database_exception (*this); + } + + // + // cli_exception + // + + cli_exception:: + cli_exception (const string& what) + : what_ (what) + { + } + + cli_exception:: + ~cli_exception () ODB_NOTHROW_NOEXCEPT + { + } + + const char* cli_exception:: + what () const ODB_NOTHROW_NOEXCEPT + { + return what_.c_str (); + } + + cli_exception* cli_exception:: + clone () const + { + return new cli_exception (*this); + } + } +} |