2 #ifndef GAUDIKERNEL_GAUDIEXCEPTION_H
3 #define GAUDIKERNEL_GAUDIEXCEPTION_H
6 #include "GaudiKernel/Kernel.h"
7 #include "GaudiKernel/StatusCode.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/System.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() ;
134 virtual const StatusCode& code ()
const {
return m_code; }
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() ; }
172 mutable std::string m_message ;
173 mutable std::string m_tag ;
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.
void setCode(unsigned long value)
Set the status code by value.
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
virtual const StatusCode & code() const
StatusCode for Exception.
std::ostream & operator<<(std::ostream &os, const GaudiException &ge)
overloaded printout to std::ostream
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 std::ostream & printOut(std::ostream &os=std::cerr) const
methods for overloaded printout to std::ostream& and MsgStream&
StatusCode & operator=(unsigned long value)
Assignment operator.