diff options
author | deva <deva> | 2005-03-27 10:18:02 +0000 |
---|---|---|
committer | deva <deva> | 2005-03-27 10:18:02 +0000 |
commit | 29ff2e254871ebc359af344d6ee453047e8ad2ec (patch) | |
tree | e2c24aa35e16fb612f3715d8a272b3cd4520537f /src/error.cc | |
parent | 63ac729b32331438a607ec5b8be046143c7592e6 (diff) |
Reimplemented the error object as a stack.
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(); + } |