diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-08-24 03:06:32 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-08-24 03:06:32 +0200 |
commit | 84a5ceeb7db03d75425d72e8a23a0bb0f267bc01 (patch) | |
tree | 7a7702429a7cdbc06144b2141eb80ee2aa462d39 /src/Core/Exception.h | |
parent | 415cd36477e152c12f91a10ad61bb719373cd9d1 (diff) | |
download | mad-84a5ceeb7db03d75425d72e8a23a0bb0f267bc01.tar mad-84a5ceeb7db03d75425d72e8a23a0bb0f267bc01.zip |
Hash-Klasse hinzugefügt
Diffstat (limited to 'src/Core/Exception.h')
-rw-r--r-- | src/Core/Exception.h | 21 |
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); |