00001 #ifndef _qpid_ExceptionHolder_h
00002 #define _qpid_ExceptionHolder_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <assert.h>
00023 #include "Exception.h"
00024 #include <boost/shared_ptr.hpp>
00025
00026 namespace qpid {
00027
00028
00029
00030
00042 class ExceptionHolder : public Exception, public boost::shared_ptr<Exception>
00043 {
00044 public:
00045 typedef boost::shared_ptr<Exception> shared_ptr;
00046
00047 ExceptionHolder() throw() {}
00048 ExceptionHolder(Exception* p) throw() : shared_ptr(p) {}
00049 ExceptionHolder(shared_ptr p) throw() : shared_ptr(p) {}
00050
00051 ExceptionHolder(const Exception& e) throw() : shared_ptr(e.clone()) {}
00052 ExceptionHolder(const std::exception& e);
00053
00054 ~ExceptionHolder() throw() {}
00055
00056 const char* what() const throw() { return get()->what(); }
00057 std::string toString() const throw() { return get()->toString(); }
00058 Exception* clone() const throw() { return get()->clone(); }
00059 void throwIf() const { if (get()) get()->throwSelf(); }
00060 void throwSelf() const { assert(get()); get()->throwSelf(); }
00061 };
00062
00063 }
00064
00065
00066
00067 #endif