diff options
Diffstat (limited to 'cpp/lib/common/Exception.cpp')
-rw-r--r-- | cpp/lib/common/Exception.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cpp/lib/common/Exception.cpp b/cpp/lib/common/Exception.cpp index 0161518011..ef88c5cb74 100644 --- a/cpp/lib/common/Exception.cpp +++ b/cpp/lib/common/Exception.cpp @@ -20,6 +20,7 @@ */ #include <Exception.h> +#include <iostream> namespace qpid { @@ -29,14 +30,32 @@ Exception::Exception(const std::string& str) throw() : whatStr(str) {} Exception::Exception(const char* str) throw() : whatStr(str) {} +Exception::Exception(const std::exception& e) throw() : whatStr(e.what()) {} + Exception::~Exception() throw() {} const char* Exception::what() const throw() { return whatStr.c_str(); } std::string Exception::toString() const throw() { return whatStr; } -Exception* Exception::clone() const throw() { return new Exception(*this); } +Exception::auto_ptr Exception::clone() const throw() { + return Exception::auto_ptr(new Exception(*this)); +} void Exception::throwSelf() const { throw *this; } +const char* Exception::defaultMessage = "Unexpected exception"; + +void Exception::log(const char* what, const char* message) { + std::cout << message << ": " << what << std::endl; +} + +void Exception::log(const std::exception& e, const char* message) { + log(e.what(), message); +} + +void Exception::logUnknown(const char* message) { + log("unknown exception.", message); +} + } // namespace qpid |