summaryrefslogtreecommitdiff
path: root/src/error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.cc')
-rw-r--r--src/error.cc46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/error.cc b/src/error.cc
index 4e3f045..34c8e33 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -22,42 +22,30 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
#include <config.h>
#include "error.h"
+#include <stdio.h>
+#include <stdarg.h>
+
Error::Error()
{
// Initialize
lastError = NULL;
-
pthread_mutex_init (&mutex, NULL);
}
+
Error::~Error()
{
}
-/*
- pthread_mutex_lock(&mutex);
- // ... do something
- pthread_mutex_unlock(&mutex);
-
- */
bool Error::hasError()
{
return lastError != NULL;
}
-/* // Perhaps!
-string Error::popAllErrorStrings()
-{
- string le = lastError;
- removeError();
- return le;
-}
-*/
string Error::popErrorString()
{
@@ -72,30 +60,30 @@ string Error::popErrorString()
return le;
}
-void Error::pushError(char* errstr)
+
+void Error::pushError(char *fmt, ...)
{
- pthread_mutex_lock(&mutex);
- printf("New Error: [%s]\n", errstr);
+ char buf[1024];
- _err_entry *err = new _err_entry;
+ pthread_mutex_lock(&mutex);
- err->errstr = errstr;
- err->prev = lastError;
- lastError = err;
- pthread_mutex_unlock(&mutex);
-}
+ va_list argp;
+ va_start(argp, fmt);
+ fprintf(stderr, "New Error: [");
+ vfprintf(stderr, fmt, argp);
+ fprintf(stderr, "]\n"); fflush(stderr);
+ vsprintf(buf, fmt, argp);
+ va_end(argp);
-void Error::pushError(string &errstr)
-{
- pthread_mutex_lock(&mutex);
_err_entry *err = new _err_entry;
- err->errstr = errstr;
+ err->errstr = string(buf);
err->prev = lastError;
lastError = err;
pthread_mutex_unlock(&mutex);
}
+
void Error::removeAllErrors()
{
while(lastError) popErrorString();