derive ATC_Error exception class from std::exception
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
#ifndef ATC_ERROR
|
#ifndef ATC_ERROR
|
||||||
#define ATC_ERROR
|
#define ATC_ERROR
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// the following two convert __LINE__ to a string
|
// the following two convert __LINE__ to a string
|
||||||
@ -23,7 +24,7 @@ namespace ATC {
|
|||||||
* @brief Base class for throwing run-time errors with descriptions
|
* @brief Base class for throwing run-time errors with descriptions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ATC_Error {
|
class ATC_Error : public std::exception {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
@ -31,17 +32,21 @@ class ATC_Error {
|
|||||||
{
|
{
|
||||||
errorDescription_ = "ERROR: " + errorDescription;
|
errorDescription_ = "ERROR: " + errorDescription;
|
||||||
ERROR_FOR_BACKTRACE
|
ERROR_FOR_BACKTRACE
|
||||||
};
|
}
|
||||||
|
|
||||||
ATC_Error(std::string location, std::string errorDescription)
|
ATC_Error(std::string location, std::string errorDescription)
|
||||||
{
|
{
|
||||||
errorDescription_ = "ERROR: " + location + ": "+ errorDescription;
|
errorDescription_ = "ERROR: " + location + ": "+ errorDescription;
|
||||||
ERROR_FOR_BACKTRACE
|
ERROR_FOR_BACKTRACE
|
||||||
};
|
}
|
||||||
|
|
||||||
std::string error_description() {
|
std::string error_description() {
|
||||||
return errorDescription_;
|
return errorDescription_;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
const char *what() const noexcept override {
|
||||||
|
return errorDescription_.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// string describing the type of error
|
// string describing the type of error
|
||||||
|
|||||||
Reference in New Issue
Block a user