2 #ifndef GAUDIKERNEL_GAUDIEXCEPTION_H
3 #define GAUDIKERNEL_GAUDIEXCEPTION_H
26 friend inline std::ostream&
operator<< ( std::ostream& os ,
28 friend inline std::ostream&
operator<< ( std::ostream& os ,
43 const std::string& Tag,
45 : m_message ( Message )
58 const std::string& Tag ,
61 : m_message ( Message )
64 , m_previous ( Exception.clone() )
74 const std::string& Tag ,
76 const std::exception& Exception )
77 : m_message ( Message )
91 m_message = Exception.
message() ;
92 m_tag = Exception.
tag () ;
93 m_code = Exception.
code () ;
94 m_previous = ( 0 == Exception.
previous() ) ?
101 if( 0 != m_previous ) {
delete m_previous ; m_previous = 0 ; }
107 if ( &Exception ==
this ) {
return *
this; }
108 m_message = Exception.
message() ;
109 m_tag = Exception.
tag () ;
110 m_code = Exception.
code () ;
111 if( 0 != m_previous ) {
delete m_previous; m_previous = 0 ; }
112 m_previous = ( 0 == Exception.
previous() ) ?
118 virtual const std::string&
message ()
const {
return m_message; }
121 virtual const std::string&
setMessage(
const std::string& newMessage ) {
122 m_message = newMessage;
return message() ;
126 virtual const std::string&
tag ()
const {
return m_tag; }
129 virtual const std::string&
setTag (
const std::string& newTag ) {
130 m_tag = newTag ;
return tag() ;
138 m_code = newStatus;
return code() ;
145 virtual std::ostream&
printOut ( std::ostream& os = std::cerr )
const {
146 os << tag() <<
" \t " << message() ;
150 default : os <<
"\t StatusCode=" << code() ; break ;
152 return ( 0 != previous() ) ? previous()->printOut( os << std::endl ) : os ;
157 os << tag() <<
"\t" << message() ;
161 default : os <<
"\t StatusCode=" << code().getCode() ; break ;
163 return ( 0 != previous() ) ? previous()->printOut( os <<
endmsg ) : os ;
170 virtual const char*
what ()
const throw() {
return message().c_str() ; }
184 {
return (0 == pge) ?
185 ( os <<
" GaudiException* points to NULL!" ) : ( os << *pge ); }
194 ( os <<
" GaudiException* points to NULL!" ) : ( os << *pge );
197 #endif // GAUDIKERNEL_GAUDIEXCEPTION_H
virtual const std::string & message() const
error message to be printed
Definition of the MsgStream class used to transmit messages.
Define general base for Gaudi exception.
virtual const StatusCode & setCode(const StatusCode &newStatus)
update the status code for the exception
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
GaudiException & operator=(const GaudiException &Exception)
assignment operator
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
std::ostream & operator<<(std::ostream &os, const GaudiException &ge)
overloaded printout to std::ostream
GaudiException(const std::string &Message, const std::string &Tag, const StatusCode &Code, const std::exception &Exception)
Constructor (3)
std::string m_tag
error message
virtual const StatusCode & code() const
StatusCode for Exception.
This class is used for returning status codes from appropriate routines.
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
virtual const char * what() const
method from std::exception
GaudiException(const std::string &Message, const std::string &Tag, const StatusCode &Code)
Constructor (1)
virtual MsgStream & printOut(MsgStream &os) const
Output the exception to the Gaudi MsgStream.
virtual const std::string & setTag(const std::string &newTag)
update name tag
GaudiException * m_previous
status code for exception
virtual std::ostream & printOut(std::ostream &os=std::cerr) const
methods for overloaded printout to std::ostream& and MsgStream&
virtual ~GaudiException()
destructor (perform the deletion of "previous" field!)
StatusCode m_code
exception tag
GaudiException(const std::string &Message, const std::string &Tag, const StatusCode &Code, const GaudiException &Exception)
Constructor (2)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GaudiException(const GaudiException &Exception)
Copy constructor (deep copying!)