From e5f9fffd8ed9c98f32b93da3626e9330ebb3f2a7 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 8 Jul 2016 00:55:51 +0300 Subject: [PATCH] Adjust the Sqrat exception class to look more like the standard std::exception. --- include/sqrat/sqratUtil.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/include/sqrat/sqratUtil.h b/include/sqrat/sqratUtil.h index e81eaa4b..77acfc89 100644 --- a/include/sqrat/sqratUtil.h +++ b/include/sqrat/sqratUtil.h @@ -402,7 +402,23 @@ public: /// \param msg A nice error message /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Exception(const string& msg) : message(msg) {} + Exception(const SQChar * msg) noexcept : message(msg) {} + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Constructs an exception + /// + /// \param msg A nice error message + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + explicit Exception(string && msg) noexcept : message(msg) {} + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Constructs an exception + /// + /// \param msg A nice error message + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + explicit Exception(const string& msg) noexcept : message(msg) {} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Copy constructor @@ -410,7 +426,7 @@ public: /// \param ex Exception to copy /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Exception(const Exception& ex) : message(ex.message) {} + Exception(const Exception& ex) noexcept : message(ex.message) {} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Returns a string identifying the exception @@ -418,10 +434,20 @@ public: /// \return A nice error message /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const string& Message() const { + const string& Message() const noexcept { return message; } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Returns a C string identifying the exception + /// + /// \return A nice error message + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + const SQChar * what() const noexcept { + return message.c_str(); + } + private: string message;