Fix export, which has been broken since the boost::signals2 changes. Also update...
[ardour.git] / libs / audiographer / audiographer / exception.h
1 #ifndef AUDIOGRAPHER_EXCEPTION_H
2 #define AUDIOGRAPHER_EXCEPTION_H
3
4 #include <exception>
5 #include <string>
6
7 #include <boost/format.hpp>
8
9 #include "audiographer/debug_utils.h"
10
11 namespace AudioGrapher
12 {
13
14 /** AudioGrapher Exception class.
15   * Automatically tells which class an exception was thrown from.
16   */
17 class Exception : public std::exception
18 {
19   public:
20         template<typename T>
21         Exception (T const & thrower, std::string const & reason)
22           : reason (boost::str (boost::format
23                         ("Exception thrown by %1%: %2%")
24                         % DebugUtils::demangled_name (thrower) % reason))
25         {}
26
27         virtual ~Exception () throw() { }
28
29         const char* what() const throw()
30         {
31                 return reason.c_str();
32         }
33
34   private:
35         std::string const reason;
36
37 };
38
39 } // namespace AudioGrapher
40
41 #endif // AUDIOGRAPHER_EXCEPTION_H