mirror of
https://github.com/thestk/stk
synced 2026-02-07 09:46:16 +00:00
Make StkError inherit from std::exception
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
//#include <cstdlib>
|
//#include <cstdlib>
|
||||||
|
|
||||||
/*! \namespace stk
|
/*! \namespace stk
|
||||||
@@ -82,7 +83,7 @@ typedef double StkFloat;
|
|||||||
be sub-classes to take care of more specific error conditions ... or
|
be sub-classes to take care of more specific error conditions ... or
|
||||||
not.
|
not.
|
||||||
*/
|
*/
|
||||||
class StkError
|
class StkError : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -110,7 +111,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
//! The constructor.
|
//! The constructor.
|
||||||
StkError(const std::string& message, Type type = StkError::UNSPECIFIED)
|
StkError(const std::string& message, Type type = StkError::UNSPECIFIED)
|
||||||
: message_(message), type_(type) {}
|
: std::exception(), message_(message), type_(type) {}
|
||||||
|
|
||||||
//! The destructor.
|
//! The destructor.
|
||||||
virtual ~StkError(void) {};
|
virtual ~StkError(void) {};
|
||||||
@@ -126,6 +127,8 @@ public:
|
|||||||
|
|
||||||
//! Returns the thrown error message as a C string.
|
//! Returns the thrown error message as a C string.
|
||||||
virtual const char *getMessageCString(void) { return message_.c_str(); }
|
virtual const char *getMessageCString(void) { return message_.c_str(); }
|
||||||
|
|
||||||
|
virtual const char *what(void) const throw() { return message_.c_str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user