From e5cab23433ec1e08a3da026525424b461d838ec4 Mon Sep 17 00:00:00 2001 From: "Grzegorz Szwoch (sound)" Date: Wed, 24 Feb 2021 11:13:47 +0100 Subject: [PATCH] Make StkError inherit from std::exception --- include/Stk.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/Stk.h b/include/Stk.h index 0b0a405..58776ab 100644 --- a/include/Stk.h +++ b/include/Stk.h @@ -6,6 +6,7 @@ #include #include #include +#include //#include /*! \namespace stk @@ -82,7 +83,7 @@ typedef double StkFloat; be sub-classes to take care of more specific error conditions ... or not. */ -class StkError +class StkError : public std::exception { public: enum Type { @@ -110,7 +111,7 @@ protected: public: //! The constructor. StkError(const std::string& message, Type type = StkError::UNSPECIFIED) - : message_(message), type_(type) {} + : std::exception(), message_(message), type_(type) {} //! The destructor. virtual ~StkError(void) {}; @@ -126,6 +127,8 @@ public: //! Returns the thrown error message as a C string. virtual const char *getMessageCString(void) { return message_.c_str(); } + + virtual const char *what(void) const throw() { return message_.c_str(); } };