aboutsummaryrefslogtreecommitdiff
path: root/exc.cpp
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-04 11:50:41 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-04 11:50:41 +0800
commit65f17438de5983ca010e10b4b24c5da65756a9b5 (patch)
treedfa88443d6cd10a14f587377f101e14359e98f56 /exc.cpp
parentd42c4bd97982c1252c5ad638a11aea5319c4be7f (diff)
added exception facilities
Diffstat (limited to 'exc.cpp')
-rw-r--r--exc.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/exc.cpp b/exc.cpp
new file mode 100644
index 0000000..648326e
--- /dev/null
+++ b/exc.cpp
@@ -0,0 +1,16 @@
+#include "exc.h"
+#include <cstdio>
+
+SyntaxError::SyntaxError(ErrCode _code) : code(_code) {}
+
+string SyntaxError::get_msg() { return this->msg; }
+
+TokenError::TokenError(string token, ErrCode code) : SyntaxError(code) {
+ static char buffer[1024]; // should be enough
+ sprintf(buffer, SYN_ERR_MSG[code], token.c_str());
+ msg = buffer;
+}
+
+NormalError::NormalError(ErrCode code) : SyntaxError(code) {
+ msg = SYN_ERR_MSG[code];
+}