Transfer 'lv2_bundled_search_path()' into 'libs/ardour/search_paths.cc'
[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/visibility.h"
10 #include "audiographer/debug_utils.h"
11
12 namespace AudioGrapher
13 {
14
15 /** AudioGrapher Exception class.
16   * Automatically tells which class an exception was thrown from.
17   */
18 class LIBAUDIOGRAPHER_API Exception : public std::exception
19 {
20   public:
21         template<typename T>
22         Exception (T const & thrower, std::string const & reason)
23           : reason (boost::str (boost::format
24                         ("Exception thrown by %1%: %2%")
25                         % DebugUtils::demangled_name (thrower) % reason))
26         {}
27
28         virtual ~Exception () throw() { }
29
30         const char* what() const throw()
31         {
32                 return reason.c_str();
33         }
34
35   private:
36         std::string const reason;
37
38 };
39
40 } // namespace AudioGrapher
41
42 #endif // AUDIOGRAPHER_EXCEPTION_H