Ardour  9.0-pre0-582-g084a23a80d
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 "pbd/compose.h"
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  : explanation(string_compose ("Exception thrown by %1: %2", DebugUtils::demangled_name (thrower), reason))
24  {}
25 
26  virtual ~Exception () throw() { }
27 
28  const char* what() const throw()
29  {
30  return explanation.c_str();
31  }
32 
33  private:
34  std::string const explanation;
35 
36 };
37 
38 } // namespace AudioGrapher
39 
40 #endif // AUDIOGRAPHER_EXCEPTION_H
Exception(T const &thrower, std::string const &reason)
Definition: exception.h:22
const char * what() const
Definition: exception.h:28
std::string const explanation
Definition: exception.h:34
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:246
std::string demangled_name(T const &obj)
Definition: demangle.h:45
Utilities for debugging.
Definition: debug_utils.h:21