| The Gaudi Framework v32r1 (f65d50dc)

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"
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/StatusCode.h"
8
9 #include <exception>
10 #include <iostream>
11 #include <string>
12
21 class GAUDI_API GaudiException : virtual public std::exception {
22 friend class StatusCode;
23
24 public:
30 GaudiException( std::string Message, std::string Tag, StatusCode Code );
31
38 GaudiException( std::string Message, std::string Tag, StatusCode Code, const GaudiException& Exception );
39
46 GaudiException( std::string Message, std::string Tag, StatusCode Code, const std::exception& Exception );
47
49 GaudiException( const GaudiException& Exception );
50
52 virtual ~GaudiException() throw();
53
55 GaudiException& operator=( const GaudiException& Exception );
56
58 virtual const std::string& message() const { return m_message; }
59
61 virtual const std::string& setMessage( const std::string& newMessage ) {
62 m_message = newMessage;
63 return message();
64 }
65
67 virtual const std::string& tag() const { return m_tag; }
68
70 virtual const std::string& setTag( const std::string& newTag ) {
71 m_tag = newTag;
72 return tag();
73 }
74
76 virtual const StatusCode& code() const { return m_code; }
77
79 virtual const StatusCode& setCode( const StatusCode& newStatus ) {
80 m_code = newStatus;
81 return code();
82 }
83
85 virtual GaudiException* previous() const { return m_previous.get(); }
86
88 virtual const std::string& backTrace() const { return m_backTrace; }
89
91 virtual std::ostream& printOut( std::ostream& os = std::cerr ) const;
92
94 virtual MsgStream& printOut( MsgStream& os ) const;
95
97 virtual GaudiException* clone() const { return new GaudiException( *this ); }
98
100 const char* what() const throw() override { return message().c_str(); }
101
102 protected:
103 std::string m_message;
104 std::string m_tag;
105 StatusCode m_code;
106 std::string m_backTrace;
107 std::unique_ptr<GaudiException> m_previous;
108 static bool s_proc;
109 };
110
112 std::ostream& operator<<( std::ostream& os, const GaudiException& ge );
113
115 std::ostream& operator<<( std::ostream& os, const GaudiException* pge );
116
118 MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
119
121 MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
122
123 #endif // GAUDIKERNEL_GAUDIEXCEPTION_H
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Kernel.h
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
GaudiException::previous
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
Definition: GaudiException.h:85
GaudiException::setCode
virtual const StatusCode & setCode(const StatusCode &newStatus)
update the status code for the exception
Definition: GaudiException.h:79
MsgStream.h
StatusCode::m_code
code_t m_code
The status code value.
Definition: StatusCode.h:225
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:108
GaudiException::setMessage
virtual const std::string & setMessage(const std::string &newMessage)
update the error message to be printed
Definition: GaudiException.h:61
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:67
std
STL namespace.
operator<<
std::ostream & operator<<(std::ostream &os, const GaudiException &ge)
overloaded printout to std::ostream
Definition: GaudiException.cpp:73
GaudiException::m_tag
std::string m_tag
error message
Definition: GaudiException.h:104
std::string
STL class.
GaudiException::what
const char * what() const override
method from std::exception
Definition: GaudiException.h:100
GaudiException::m_message
std::string m_message
Definition: GaudiException.h:103
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
std::exception
STL class.
StatusCode::message
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:169
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:76
std::unique_ptr< GaudiException >
Message
The Message class.
Definition: Message.h:17
GaudiException::clone
virtual GaudiException * clone() const
clone operation
Definition: GaudiException.h:97
GaudiException::m_backTrace
std::string m_backTrace
status code for exception
Definition: GaudiException.h:106
GaudiException::backTrace
virtual const std::string & backTrace() const
return the stack trace at instantiation
Definition: GaudiException.h:88
GaudiException::setTag
virtual const std::string & setTag(const std::string &newTag)
update name tag
Definition: GaudiException.h:70
std::string::c_str
T c_str(T... args)
GaudiException::m_code
StatusCode m_code
exception tag
Definition: GaudiException.h:105
StatusCode.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
std::ostream
STL class.
GaudiException::m_previous
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation
Definition: GaudiException.h:107