diff options
Diffstat (limited to 'src/error.cc')
-rw-r--r-- | src/error.cc | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/error.cc b/src/error.cc index 4056aa9..b166042 100644 --- a/src/error.cc +++ b/src/error.cc @@ -29,7 +29,7 @@ Error::Error() { // Initialize - removeError(); + lastError = NULL; } Error::~Error() @@ -38,36 +38,51 @@ Error::~Error() bool Error::hasError() { - return error; + return lastError != NULL; } -string Error::getErrorString() +/* // Perhaps! +string Error::popAllErrorStrings() { string le = lastError; removeError(); return le; } +*/ -void Error::setError(char* errstr) +string Error::popErrorString() +{ + if(lastError == NULL) return string(""); + + _err_entry *err = lastError; + string le = err->errstr; + lastError = err->prev; + delete err; + return le; +} + +void Error::pushError(char* errstr) { printf("New Error: [%s]\n", errstr); - error = true; - lastError.append(errstr); - lastError.append("\n"); + _err_entry *err = new _err_entry; - printf("All Errors: [%s]\n", lastError.c_str()); + err->errstr = errstr; + err->prev = lastError; + lastError = err; } -void Error::setError(string &errstr) +void Error::pushError(string &errstr) { - error = true; - lastError.append(errstr); - lastError.append("\n"); + _err_entry *err = new _err_entry; + + err->errstr = errstr; + err->prev = lastError; + lastError = err; } -void Error::removeError() +void Error::removeAllErrors() { - error = false; - lastError = string(""); + while(lastError) popErrorString(); + } |