1 #ifndef QPID_EXCEPTIONHOLDER_H
2 #define QPID_EXCEPTIONHOLDER_H
25 #include <boost/shared_ptr.hpp>
33 virtual void raise()
const=0;
34 virtual std::string
what()
const=0;
50 void raise()
const {
if (wrapper.get()) wrapper->raise() ; }
51 std::string
what()
const {
return wrapper.get() ? wrapper->what() : std::string(); }
52 bool empty()
const {
return !wrapper.get(); }
53 operator bool()
const {
return !
empty(); }
54 void reset() { wrapper.reset(); }
57 template <
class Ex>
struct Wrapper :
public Raisable {
58 Wrapper(Ex* ptr) : exception(ptr) {}
59 void raise()
const {
throw *exception; }
60 std::string
what()
const {
return exception->what(); }
61 boost::shared_ptr<Ex> exception;
63 template <
class Ex>
void wrap(Ex* ex) { wrapper.reset(
new Wrapper<Ex>(ex)); }
64 boost::shared_ptr<Raisable> wrapper;