Jpp
JDAQException.hh
Go to the documentation of this file.
1 #ifndef __JDAQEXCEPTION__
2 #define __JDAQEXCEPTION__
3 
4 #include <exception>
5 #include <ostream>
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace KM3NETDAQ {
13 
14 
15  /**
16  * General exception
17  */
18  class JDAQException : public std::exception {
19  public:
20  /**
21  * Constructor.
22  *
23  * \param error error message
24  */
25  JDAQException(const std::string& error) :
26  std::exception(),
27  buffer(error)
28  {}
29 
30 
31  /**
32  * Destructor.
33  */
34  ~JDAQException() throw()
35  {}
36 
37 
38  /**
39  * Get error message.
40  *
41  * \return error message
42  */
43  virtual const char* what() const throw()
44  {
45  return buffer.c_str();
46  }
47 
48 
49  /**
50  * Print error message of JDAQException.
51  *
52  * \param out output stream
53  * \param exception exception
54  */
55  friend inline std::ostream& operator<<(std::ostream& out, const JDAQException& exception)
56  {
57  return out << exception.what();
58  }
59 
60  private:
61  const std::string buffer;
62  };
63 }
64 
65 #endif
KM3NETDAQ::JDAQException::buffer
const std::string buffer
Definition: JDAQException.hh:61
KM3NETDAQ::JDAQException::~JDAQException
~JDAQException()
Destructor.
Definition: JDAQException.hh:34
KM3NETDAQ::JDAQException::what
virtual const char * what() const
Get error message.
Definition: JDAQException.hh:43
KM3NETDAQ::JDAQException
General exception.
Definition: JDAQException.hh:18
KM3NETDAQ::JDAQException::operator<<
friend std::ostream & operator<<(std::ostream &out, const JDAQException &exception)
Print error message of JDAQException.
Definition: JDAQException.hh:55
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
KM3NETDAQ::JDAQException::JDAQException
JDAQException(const std::string &error)
Constructor.
Definition: JDAQException.hh:25