00001
00009 #include <atoms/error.hh>
00010 #include <stdarg.h>
00011
00012 using namespace atoms;
00013
00014 Error::Error(const Error &o) : what_(o.what_), owner_(o.owner_) {
00015 if (o.owner_) {
00016 what_ = strdup(what_);
00017 if (what_ == NULL)
00018 throw MemoryError();
00019 }
00020 }
00021
00022 void Error::logCaught(DebugLogger &logger, DebugLogger::Level level,
00023 const char *extraFmt, ...) const {
00024 va_list(args);
00025 va_start(args,extraFmt);
00026 logger.log(level, "Caught exception: %s", what());
00027 #ifdef ATOMS_DEBUG
00028 logger.log(level, "Exception has backtrace");
00029 b.print();
00030 #endif
00031 if (extraFmt != NULL)
00032 logger.log(level, extraFmt, args);
00033 va_end(args);
00034 }