From 13d613709534e5d77798b9ea9ca5594610445420 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 13 Oct 2015 20:07:35 +0100 Subject: Centralize common exceptions --- slicer/db/exceptions.cpp | 6 ++++++ slicer/db/exceptions.h | 14 ++++++++++++++ slicer/db/sqlSelectDeserializer.cpp | 3 +-- slicer/db/sqlSelectDeserializer.h | 5 ----- slicer/db/testSelect.cpp | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 slicer/db/exceptions.cpp create mode 100644 slicer/db/exceptions.h diff --git a/slicer/db/exceptions.cpp b/slicer/db/exceptions.cpp new file mode 100644 index 0000000..50099bd --- /dev/null +++ b/slicer/db/exceptions.cpp @@ -0,0 +1,6 @@ +#include "exceptions.h" + +namespace Slicer { + UnsupportedModelType::UnsupportedModelType() : std::invalid_argument("Unspported model type") { } +} + diff --git a/slicer/db/exceptions.h b/slicer/db/exceptions.h new file mode 100644 index 0000000..8673627 --- /dev/null +++ b/slicer/db/exceptions.h @@ -0,0 +1,14 @@ +#ifndef SLICER_DB_EXCEPTIONS_H +#define SLICER_DB_EXCEPTIONS_H + +#include + +namespace Slicer { + class UnsupportedModelType : public std::invalid_argument { + public: + UnsupportedModelType(); + }; +} + +#endif + diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index d4198b5..ba5f944 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -1,5 +1,6 @@ #include "sqlSelectDeserializer.h" #include "sqlSource.h" +#include "exceptions.h" #include namespace Slicer { @@ -7,8 +8,6 @@ namespace Slicer { TooManyRowsReturned::TooManyRowsReturned() : std::runtime_error("Too many rows returned") { } - UnsupportedModelType::UnsupportedModelType() : std::invalid_argument("Unspported model type") { } - SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand & c, IceUtil::Optional tc) : cmd(c), typeIdColName(tc) diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 42a0243..3d73c94 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -16,11 +16,6 @@ namespace Slicer { TooManyRowsReturned(); }; - class UnsupportedModelType : public std::invalid_argument { - public: - UnsupportedModelType(); - }; - class DLL_PUBLIC SqlSelectDeserializer : public Slicer::Deserializer { public: SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional typeIdCol = IceUtil::Optional()); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index 3af5282..da04b82 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -6,6 +6,7 @@ #include #include "sqlSelectDeserializer.h" #include +#include "exceptions.h" class StandardMockDatabase : public PQ::Mock { public: -- cgit v1.2.3