From 983cf020701c558eb35a1fa46355886cee4d326f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 17 Sep 2016 02:48:28 +0100 Subject: Move exceptions to their own files --- icespider/core/core.cpp | 7 +------ icespider/core/core.h | 18 ------------------ icespider/core/exceptions.cpp | 10 ++++++++++ icespider/core/exceptions.h | 27 +++++++++++++++++++++++++++ icespider/core/ihttpRequest.cpp | 2 +- icespider/unittests/testApp.cpp | 1 + 6 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 icespider/core/exceptions.cpp create mode 100644 icespider/core/exceptions.h diff --git a/icespider/core/core.cpp b/icespider/core/core.cpp index 096b367..fc50bd1 100644 --- a/icespider/core/core.cpp +++ b/icespider/core/core.cpp @@ -1,16 +1,11 @@ #include "core.h" +#include "exceptions.h" #include #include namespace IceSpider { const boost::filesystem::path Core::defaultConfig("config/ice.properties"); - DefineHttpEx(Http400_BadRequest, 400, "Bad Request"); - DefineHttpEx(Http404_NotFound, 404, "Not found"); - DefineHttpEx(Http405_MethodNotAllowed, 405, "Method Not Allowed"); - DefineHttpEx(Http406_NotAcceptable, 406, "Not Acceptable"); - DefineHttpEx(Http415_UnsupportedMediaType, 415, "Unsupported Media Type"); - static bool operator/=(const PathElements & pathparts, const IRouteHandler * r) diff --git a/icespider/core/core.h b/icespider/core/core.h index c7c762f..77d338e 100644 --- a/icespider/core/core.h +++ b/icespider/core/core.h @@ -7,25 +7,7 @@ #include #include -#define DeclareHttpEx(Name) \ - class Name : public ::IceSpider::HttpException { \ - public: \ - Name(); \ - static const int code; \ - static const std::string message; \ - } -#define DefineHttpEx(Name, Code, Message) \ - Name::Name() : ::IceSpider::HttpException(code, message) { } \ - const int Name::code(Code); \ - const std::string Name::message(Message); - namespace IceSpider { - DeclareHttpEx(Http400_BadRequest); - DeclareHttpEx(Http404_NotFound); - DeclareHttpEx(Http405_MethodNotAllowed); - DeclareHttpEx(Http406_NotAcceptable); - DeclareHttpEx(Http415_UnsupportedMediaType); - class DLL_PUBLIC Core { public: typedef std::vector LengthRoutes; diff --git a/icespider/core/exceptions.cpp b/icespider/core/exceptions.cpp new file mode 100644 index 0000000..d249fcc --- /dev/null +++ b/icespider/core/exceptions.cpp @@ -0,0 +1,10 @@ +#include "exceptions.h" + +namespace IceSpider { + DefineHttpEx(Http400_BadRequest, 400, "Bad Request"); + DefineHttpEx(Http404_NotFound, 404, "Not found"); + DefineHttpEx(Http405_MethodNotAllowed, 405, "Method Not Allowed"); + DefineHttpEx(Http406_NotAcceptable, 406, "Not Acceptable"); + DefineHttpEx(Http415_UnsupportedMediaType, 415, "Unsupported Media Type"); +} + diff --git a/icespider/core/exceptions.h b/icespider/core/exceptions.h new file mode 100644 index 0000000..71e6e71 --- /dev/null +++ b/icespider/core/exceptions.h @@ -0,0 +1,27 @@ +#ifndef ICESPIDER_EXCEPTIONS_H +#define ICESPIDER_EXCEPTIONS_H + +#include "http.h" + +#define DeclareHttpEx(Name) \ + class Name : public ::IceSpider::HttpException { \ + public: \ + Name(); \ + static const int code; \ + static const std::string message; \ + } +#define DefineHttpEx(Name, Code, Message) \ + Name::Name() : ::IceSpider::HttpException(code, message) { } \ + const int Name::code(Code); \ + const std::string Name::message(Message); + +namespace IceSpider { + DeclareHttpEx(Http400_BadRequest); + DeclareHttpEx(Http404_NotFound); + DeclareHttpEx(Http405_MethodNotAllowed); + DeclareHttpEx(Http406_NotAcceptable); + DeclareHttpEx(Http415_UnsupportedMediaType); +} + +#endif + diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp index a49df42..d9abecd 100644 --- a/icespider/core/ihttpRequest.cpp +++ b/icespider/core/ihttpRequest.cpp @@ -1,7 +1,7 @@ #include "ihttpRequest.h" #include "irouteHandler.h" #include "util.h" -#include "core.h" +#include "exceptions.h" #include namespace IceSpider { diff --git a/icespider/unittests/testApp.cpp b/icespider/unittests/testApp.cpp index 087d95d..80cecda 100644 --- a/icespider/unittests/testApp.cpp +++ b/icespider/unittests/testApp.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3