diff options
author | randomdan <randomdan@localhost> | 2011-08-31 21:48:04 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-08-31 21:48:04 +0000 |
commit | c6375740de642a3c954fe19614fbe55e1c8d2c9c (patch) | |
tree | 77abf662b898321a61058fb0a0da603e336bcad9 /project2/common/exceptions.cpp | |
parent | Adds RDBMS table caching solution (diff) | |
download | project2-c6375740de642a3c954fe19614fbe55e1c8d2c9c.tar.bz2 project2-c6375740de642a3c954fe19614fbe55e1c8d2c9c.tar.xz project2-c6375740de642a3c954fe19614fbe55e1c8d2c9c.zip |
The big reshuffle
Diffstat (limited to 'project2/common/exceptions.cpp')
-rw-r--r-- | project2/common/exceptions.cpp | 26 |
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; +} + |