summaryrefslogtreecommitdiffstats
path: root/src/Core/Exception.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Exception.h')
-rw-r--r--src/Core/Exception.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/Core/Exception.h b/src/Core/Exception.h
index fb6fae7..f12b3df 100644
--- a/src/Core/Exception.h
+++ b/src/Core/Exception.h
@@ -22,12 +22,13 @@
#include "export.h"
+#include <exception>
#include <string>
namespace Mad {
namespace Core {
-class MAD_CORE_EXPORT Exception {
+class MAD_CORE_EXPORT Exception : public std::exception {
public:
enum ErrorCode {
SUCCESS = 0x0000, UNEXPECTED_PACKET = 0x0001, INVALID_ACTION = 0x0002, NOT_AVAILABLE = 0x0003, NOT_FINISHED = 0x0004, NOT_IMPLEMENTED = 0x0005,
@@ -46,18 +47,28 @@ class MAD_CORE_EXPORT Exception {
long subCode;
long subSubCode;
+ std::string whatStr;
+
+ void updateWhatStr();
+
public:
Exception(const std::string &where0, ErrorCode errorCode0 = SUCCESS, long subCode0 = 0, long subSubCode0 = 0)
- : where(where0), errorCode(errorCode0), subCode(subCode0), subSubCode(subSubCode0) {}
- Exception(ErrorCode errorCode0 = SUCCESS, long subCode0 = 0, long subSubCode0 = 0) : errorCode(errorCode0), subCode(subCode0), subSubCode(subSubCode0) {}
- virtual ~Exception() {}
+ : where(where0), errorCode(errorCode0), subCode(subCode0), subSubCode(subSubCode0) {
+ updateWhatStr();
+ }
+ Exception(ErrorCode errorCode0 = SUCCESS, long subCode0 = 0, long subSubCode0 = 0) : errorCode(errorCode0), subCode(subCode0), subSubCode(subSubCode0) {
+ updateWhatStr();
+ }
+ virtual ~Exception() throw () {}
const std::string& getWhere() const {return where;}
ErrorCode getErrorCode() const {return errorCode;}
long getSubCode() const {return subCode;}
long getSubSubCode() const {return subSubCode;}
- std::string strerror() const;
+ virtual const char* what() const throw () {
+ return whatStr.c_str();
+ }
operator bool() const {
return (errorCode != SUCCESS);