diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-09 18:26:12 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-09 18:26:12 +0000 |
commit | 535fc84bc9d7d5bb177c6ca4d42a17fe594059cd (patch) | |
tree | 805711274c6b32db4eb4160dcb2dfe0373e73f8a | |
parent | Add specific exception for invalid conversions during extract and tests over ... (diff) | |
download | libdbpp-535fc84bc9d7d5bb177c6ca4d42a17fe594059cd.tar.bz2 libdbpp-535fc84bc9d7d5bb177c6ca4d42a17fe594059cd.tar.xz libdbpp-535fc84bc9d7d5bb177c6ca4d42a17fe594059cd.zip |
Add exception messages with adhoc exception
-rw-r--r-- | libdbpp/selectcommand.cpp | 13 | ||||
-rw-r--r-- | libdbpp/selectcommand.h | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libdbpp/selectcommand.cpp b/libdbpp/selectcommand.cpp index 792af12..d904b35 100644 --- a/libdbpp/selectcommand.cpp +++ b/libdbpp/selectcommand.cpp @@ -2,11 +2,24 @@ #include "error.h" #include <boost/multi_index_container.hpp> #include <boost/multi_index/ordered_index.hpp> +#include <buffer.h> namespace DB { ColumnIndexOutOfRange::ColumnIndexOutOfRange(unsigned int n) : colNo(n) { } + std::string + ColumnIndexOutOfRange::message() const throw() + { + return stringf("Column (%u) index out of range", colNo); + } + ColumnDoesNotExist::ColumnDoesNotExist(const Glib::ustring & n) : colName(n) { } + + std::string + ColumnDoesNotExist::message() const throw() + { + return stringf("Column (%s) does not exist", colName.c_str()); + } }; DB::SelectCommand::SelectCommand(const std::string & sql) : diff --git a/libdbpp/selectcommand.h b/libdbpp/selectcommand.h index 8c9af13..e82a532 100644 --- a/libdbpp/selectcommand.h +++ b/libdbpp/selectcommand.h @@ -11,18 +11,21 @@ #include <boost/function/function_fwd.hpp> #include <boost/shared_ptr.hpp> #include <visibility.h> +#include <exception.h> namespace DB { class Column; - class ColumnIndexOutOfRange : public Error { + class DLL_PUBLIC ColumnIndexOutOfRange : public AdHoc::Exception<Error> { public: ColumnIndexOutOfRange(unsigned int n); + std::string message() const throw() override; const unsigned int colNo; }; - class ColumnDoesNotExist : public Error { + class DLL_PUBLIC ColumnDoesNotExist : public AdHoc::Exception<Error> { public: ColumnDoesNotExist(const Glib::ustring & n); + std::string message() const throw() override; const Glib::ustring colName; }; |