Ardour  8.12
exception.h
Go to the documentation of this file.
1 #ifndef AUDIOGRAPHER_EXCEPTION_H
2 #define AUDIOGRAPHER_EXCEPTION_H
3 
4 #include <exception>
5 #include <string>
6 
7 #include <boost/format.hpp>
8 
11 
12 namespace AudioGrapher
13 {
14 
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
Exception(T const &thrower, std::string const &reason)
Definition: exception.h:22
const char * what() const
Definition: exception.h:30
std::string const reason
Definition: exception.h:36
std::string demangled_name(T const &obj)
Definition: demangle.h:46
Utilities for debugging.
Definition: debug_utils.h:21