summaryrefslogtreecommitdiff
path: root/project2/common/exceptions.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-08-31 21:48:04 +0000
committerrandomdan <randomdan@localhost>2011-08-31 21:48:04 +0000
commit05b8bed896e5fe8c1841869e5d6e8e837e72c10a (patch)
tree77abf662b898321a61058fb0a0da603e336bcad9 /project2/common/exceptions.cpp
parentAdds RDBMS table caching solution (diff)
downloadproject2-05b8bed896e5fe8c1841869e5d6e8e837e72c10a.tar.bz2
project2-05b8bed896e5fe8c1841869e5d6e8e837e72c10a.tar.xz
project2-05b8bed896e5fe8c1841869e5d6e8e837e72c10a.zip
The big reshuffle
Diffstat (limited to 'project2/common/exceptions.cpp')
-rw-r--r--project2/common/exceptions.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/project2/common/exceptions.cpp b/project2/common/exceptions.cpp
new file mode 100644
index 0000000..ddf8e94
--- /dev/null
+++ b/project2/common/exceptions.cpp
@@ -0,0 +1,26 @@
+#include "exceptions.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+numeric_error::numeric_error(int e) :
+ err(e),
+ buf(NULL)
+{
+}
+
+numeric_error::~numeric_error() throw()
+{
+ free(buf);
+}
+
+const char *
+numeric_error::what() const throw()
+{
+ if (!buf) {
+ if (asprintf(&buf, "%d", err) < 1) {
+ throw std::bad_alloc();
+ }
+ }
+ return buf;
+}
+