Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTriggerException.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGEREXCEPTION__
2 #define __JTRIGGEREXCEPTION__
3 
4 #include <exception>
5 #include <istream>
6 #include <ostream>
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JTRIGGER {}
14 namespace JPP { using namespace JTRIGGER; }
15 
16 namespace JTRIGGER {
17 
18 
19  /**
20  * General exception
21  */
22  class JTriggerException : public std::exception {
23  public:
24  /**
25  * Constructor.
26  *
27  * \param error error message
28  */
29  JTriggerException(const std::string& error) :
30  std::exception(),
31  buffer(error)
32  {}
33 
34 
35  /**
36  * Destructor.
37  */
39  {}
40 
41 
42  /**
43  * Get error message.
44  *
45  * \return error message
46  */
47  virtual const char* what() const throw() { return buffer.c_str(); }
48 
49  private:
50  const std::string buffer;
51  };
52 
53 
54  /**
55  * Print error message of JTriggerException.
56  *
57  * \param out output stream
58  * \param exception JTriggerException
59  */
60  inline std::ostream& operator<<(std::ostream& out, const JTriggerException& exception)
61  {
62  return out << exception.what();
63  }
64 }
65 
66 #endif
virtual const char * what() const
Get error message.
JTriggerException(const std::string &error)
Constructor.
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)