diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-04 11:50:41 +0800 |
commit | 65f17438de5983ca010e10b4b24c5da65756a9b5 (patch) | |
tree | dfa88443d6cd10a14f587377f101e14359e98f56 /exc.h | |
parent | d42c4bd97982c1252c5ad638a11aea5319c4be7f (diff) |
added exception facilities
Diffstat (limited to 'exc.h')
-rw-r--r-- | exc.h | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +#ifndef EXC_H +#define EXC_H + +#include "consts.h" +#include <string> + +using std::string; + +/** @class GeneralError + * The top-level exception + */ +class GeneralError { + public: + virtual string get_msg() = 0; /**< Extract error message */ +}; + +class SyntaxError : public GeneralError { + protected: + string msg; /**< Error mesg */ + ErrCode code; /**< Error code */ + public: + + SyntaxError(ErrCode code); /**< Construct an SyntaxError */ + string get_msg(); /**< Get the error message */ +}; + +class TokenError : public SyntaxError { + public: + TokenError(string token, ErrCode code); /**< Construct an TokenError */ +}; + +class NormalError : public SyntaxError { + public: + NormalError(ErrCode code); +}; + +#endif |