The Gaudi Framework  v30r4 (9b837755)
GaudiException.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_GAUDIEXCEPTION_H
2 #define GAUDIKERNEL_GAUDIEXCEPTION_H
3 
4 // Include files
5 #include "GaudiKernel/Kernel.h"
8 
9 #include <exception>
10 #include <iostream>
11 #include <string>
12 
21 class GAUDI_API GaudiException : virtual public std::exception
22 {
23  friend class StatusCode;
24 
25 public:
32 
40 
48 
50  GaudiException( const GaudiException& Exception );
51 
53  virtual ~GaudiException() throw();
54 
56  GaudiException& operator=( const GaudiException& Exception );
57 
59  virtual const std::string& message() const { return m_message; }
60 
62  virtual const std::string& setMessage( const std::string& newMessage )
63  {
64  m_message = newMessage;
65  return message();
66  }
67 
69  virtual const std::string& tag() const { return m_tag; }
70 
72  virtual const std::string& setTag( const std::string& newTag )
73  {
74  m_tag = newTag;
75  return tag();
76  }
77 
79  virtual const StatusCode& code() const { return m_code; }
80 
82  virtual const StatusCode& setCode( const StatusCode& newStatus )
83  {
84  m_code = newStatus;
85  return code();
86  }
87 
89  virtual GaudiException* previous() const { return m_previous.get(); }
90 
92  virtual const std::string& backTrace() const { return m_backTrace; }
93 
95  virtual std::ostream& printOut( std::ostream& os = std::cerr ) const;
96 
98  virtual MsgStream& printOut( MsgStream& os ) const;
99 
101  virtual GaudiException* clone() const { return new GaudiException( *this ); }
102 
104  const char* what() const throw() override { return message().c_str(); }
105 
106 protected:
112  static bool s_proc;
113 };
114 
117 
120 
122 MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
123 
125 MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
126 
127 #endif // GAUDIKERNEL_GAUDIEXCEPTION_H
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual const std::string & backTrace() const
return the stack trace at instantiation
Define general base for Gaudi exception.
virtual const StatusCode & setCode(const StatusCode &newStatus)
update the status code for the exception
code_t m_code
The status code value.
Definition: StatusCode.h:244
static bool s_proc
"previous" element in the linked list
virtual const std::string & setMessage(const std::string &newMessage)
update the error message to be printed
STL namespace.
std::ostream & operator<<(std::ostream &os, const GaudiException &ge)
overloaded printout to std::ostream
const char * what() const override
method from std::exception
std::string m_tag
error message
virtual const StatusCode & code() const
StatusCode for Exception.
STL class.
std::string m_message
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
virtual GaudiException * clone() const
clone operation
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
The Message class.
Definition: Message.h:15
std::string m_backTrace
status code for exception
virtual const std::string & setTag(const std::string &newTag)
update name tag
T c_str(T...args)
StatusCode m_code
exception tag
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:183
#define GAUDI_API
Definition: Kernel.h:71
STL class.
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation