From 535fc84bc9d7d5bb177c6ca4d42a17fe594059cd Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 9 Nov 2015 18:26:12 +0000 Subject: Add exception messages with adhoc exception --- libdbpp/selectcommand.cpp | 13 +++++++++++++ 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 #include +#include 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 #include #include +#include namespace DB { class Column; - class ColumnIndexOutOfRange : public Error { + class DLL_PUBLIC ColumnIndexOutOfRange : public AdHoc::Exception { 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 { public: ColumnDoesNotExist(const Glib::ustring & n); + std::string message() const throw() override; const Glib::ustring colName; }; -- cgit v1.2.3