diff options
Diffstat (limited to 'lib/Exceptions.cc')
-rw-r--r-- | lib/Exceptions.cc | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lib/Exceptions.cc b/lib/Exceptions.cc index fe3aecc..85b4429 100644 --- a/lib/Exceptions.cc +++ b/lib/Exceptions.cc @@ -5,9 +5,6 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef HAVE_GLIB -#include <glib.h> -#endif #ifdef DEBUG #include <iostream> #endif @@ -21,6 +18,8 @@ char GeneralException::t[BUFSIZ]; +std::vector<String> Base::context; + GeneralException::GeneralException(String emsg) : msg(emsg.strdup()) { #ifdef DEBUG printm(M_BARE, String(_("Generating a General Exception error: '")) + msg + "'.\n"); @@ -179,6 +178,10 @@ void xexit(int status) throw (GeneralException) { throw Exit(status); } +void xexception(const String & err) throw (GeneralException) { + throw GeneralException(err); +} + char * Base::strdup(const char * s) { return xstrdup(s); } @@ -239,3 +242,28 @@ pid_t Base::fork() { void Base::exit(int status) { xexit(status); } + +void Base::flushcontext() { + context.clear(); +} + +void Base::pushcontext(const String & c) { + context.push_back(c); +} + +void Base::popcontext() { + context.pop_back(); +} + +void Base::exception(const String & err) { + int c; + std::vector<String>::iterator i; + printm(M_ERROR, "Error detected, showing context.\n"); + for (i = context.begin(), c = 0; i != context.end(); i++, c++) { + printm(M_ERROR, " (%i) - " + *i + "\n", c); + } + + printm(M_ERROR, " Error description: " + err); + + xexception(err); +} |