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