1 #ifndef AUDIOGRAPHER_EXCEPTION_H
2 #define AUDIOGRAPHER_EXCEPTION_H
8 #include <boost/format.hpp>
10 namespace AudioGrapher
13 class Exception : public std::exception
17 Exception (T const & thrower, std::string const & reason)
18 : reason (boost::str (boost::format (
19 "Exception thrown by %1%: %2%") % name (thrower) % reason))
22 virtual ~Exception () throw() { }
24 const char* what() const throw()
26 return reason.c_str();
31 std::string name (T const & obj)
35 char * res = abi::__cxa_demangle (typeid(obj).name(), 0, 0, &status);
42 return typeid(obj).name();
46 std::string const reason;
50 } // namespace AudioGrapher
52 #endif // AUDIOGRAPHER_EXCEPTION_H