From 6071376d4262f40e28a9c90f31370e1ecc4ba15a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 10 Apr 2022 15:25:37 -0400 Subject: [PATCH] derive ATC_Error exception class from std::exception --- lib/atc/ATC_Error.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/atc/ATC_Error.h b/lib/atc/ATC_Error.h index 62c22158cf..f4f3f84c24 100644 --- a/lib/atc/ATC_Error.h +++ b/lib/atc/ATC_Error.h @@ -3,6 +3,7 @@ #ifndef ATC_ERROR #define ATC_ERROR +#include #include // the following two convert __LINE__ to a string @@ -23,7 +24,7 @@ namespace ATC { * @brief Base class for throwing run-time errors with descriptions */ -class ATC_Error { +class ATC_Error : public std::exception { public: // constructor @@ -31,17 +32,21 @@ class ATC_Error { { errorDescription_ = "ERROR: " + errorDescription; ERROR_FOR_BACKTRACE - }; + } ATC_Error(std::string location, std::string errorDescription) { errorDescription_ = "ERROR: " + location + ": "+ errorDescription; ERROR_FOR_BACKTRACE - }; + } std::string error_description() { return errorDescription_; - }; + } + + const char *what() const noexcept override { + return errorDescription_.c_str(); + } private: // string describing the type of error