The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
GaudiException Class Reference

Define general base for Gaudi exception. More...

#include <GaudiKernel/GaudiException.h>

Inheritance diagram for GaudiException:
Collaboration diagram for GaudiException:

Public Member Functions

 GaudiException (std::string Message, std::string Tag, StatusCode Code)
 Constructor (1)
 
 GaudiException (std::string Message, std::string Tag, StatusCode Code, const GaudiException &Exception)
 Constructor (2)
 
 GaudiException (std::string Message, std::string Tag, StatusCode Code, const std::exception &Exception)
 Constructor (3)
 
 GaudiException (const GaudiException &Exception)
 Copy constructor (deep copying!)
 
virtual ~GaudiException () throw ()
 destructor (perform the deletion of "previous" field!)
 
GaudiExceptionoperator= (const GaudiException &Exception)
 assignment operator
 
virtual const std::string & message () const
 error message to be printed
 
virtual const std::string & setMessage (const std::string &newMessage)
 update the error message to be printed
 
virtual const std::string & tag () const
 name tag for the exception, or exception type
 
virtual const std::string & setTag (const std::string &newTag)
 update name tag
 
virtual const StatusCodecode () const
 StatusCode for Exception.
 
virtual const StatusCodesetCode (const StatusCode &newStatus)
 update the status code for the exception
 
virtual GaudiExceptionprevious () const
 get the previous exception ( "previous" element in the linked list)
 
virtual const std::string & backTrace () const
 return the stack trace at instantiation
 
virtual std::ostream & printOut (std::ostream &os=std::cerr) const
 methods for overloaded printout to std::ostream& and MsgStream&
 
virtual MsgStreamprintOut (MsgStream &os) const
 Output the exception to the Gaudi MsgStream.
 
virtual GaudiExceptionclone () const
 clone operation
 
const char * what () const override throw ()
 method from std::exception
 

Protected Attributes

std::string m_message
 
std::string m_tag
 error message
 
StatusCode m_code
 exception tag
 
std::string m_backTrace
 status code for exception
 
std::unique_ptr< GaudiExceptionm_previous
 stack trace at instantiation
 

Static Protected Attributes

static bool s_proc
 "previous" element in the linked list
 

Friends

class StatusCode
 
std::ostream & operator<< (std::ostream &os, const GaudiException &ge)
 overloaded printout to std::ostream
 
std::ostream & operator<< (std::ostream &os, const GaudiException *pge)
 overloaded printout to std::ostream
 
MsgStreamoperator<< (MsgStream &os, const GaudiException &ge)
 overloaded printout to MsgStream
 
MsgStreamoperator<< (MsgStream &os, const GaudiException *pge)
 overloaded printout to MsgStream
 

Detailed Description

Define general base for Gaudi exception.

Author
Vanya Belyaev
Sebastien Ponce

Definition at line 29 of file GaudiException.h.

Constructor & Destructor Documentation

◆ GaudiException() [1/4]

GaudiException::GaudiException ( std::string Message,
std::string Tag,
StatusCode Code )

Constructor (1)

Parameters
Messageerror message
Tag"name tag", or exeption type
Codestatus code

Definition at line 26 of file GaudiException.cpp.

27 : m_message( std::move( Message ) ), m_tag( std::move( Tag ) ), m_code( std::move( Code ) ) {
28 s_proc = true;
29 m_backTrace = captureBacktrace( m_code );
30}
static bool s_proc
"previous" element in the linked list
std::string m_message
StatusCode m_code
exception tag
std::string m_tag
error message
std::string m_backTrace
status code for exception

◆ GaudiException() [2/4]

GaudiException::GaudiException ( std::string Message,
std::string Tag,
StatusCode Code,
const GaudiException & Exception )

Constructor (2)

Parameters
Messageerror message
Tag"name tag", or exeption type
Codestatus code
Exception"previous" exception

Definition at line 32 of file GaudiException.cpp.

33 : m_message( std::move( Message ) )
34 , m_tag( std::move( Tag ) )
35 , m_code( std::move( Code ) )
36 , m_previous( Exception.clone() ) {
37 // Do not capture backtrace in outer chained exceptions, so only innermost exception is printed
38}
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation

◆ GaudiException() [3/4]

GaudiException::GaudiException ( std::string Message,
std::string Tag,
StatusCode Code,
const std::exception & Exception )

Constructor (3)

Parameters
Messageerror message
Tag"name tag", or exeption type
Codestatus code
Exception"previous" exception (used to improve the error message)

Definition at line 40 of file GaudiException.cpp.

41 : m_message( std::move( Message ) ), m_tag( std::move( Tag ) ), m_code( std::move( Code ) ) {
42 s_proc = true;
43 m_message += ": " + System::typeinfoName( typeid( Exception ) ) + ", " + Exception.what();
44 m_backTrace = captureBacktrace( m_code );
45}
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ GaudiException() [4/4]

GaudiException::GaudiException ( const GaudiException & Exception)

Copy constructor (deep copying!)

Definition at line 47 of file GaudiException.cpp.

48 : std::exception( Exception )
49 , m_message{ Exception.message() }
50 , m_tag{ Exception.tag() }
51 , m_code{ Exception.code() }
52 , m_backTrace{ Exception.backTrace() }
53 , m_previous{ Exception.previous() ? Exception.previous()->clone() : nullptr } {
54 s_proc = true;
55}

◆ ~GaudiException()

GaudiException::~GaudiException ( )
throw ( )
virtual

destructor (perform the deletion of "previous" field!)

Definition at line 57 of file GaudiException.cpp.

57{ s_proc = false; }

Member Function Documentation

◆ backTrace()

virtual const std::string & GaudiException::backTrace ( ) const
inlinevirtual

return the stack trace at instantiation

Definition at line 96 of file GaudiException.h.

96{ return m_backTrace; }

◆ clone()

virtual GaudiException * GaudiException::clone ( ) const
inlinevirtual

clone operation

Reimplemented in UpdateManagerException.

Definition at line 105 of file GaudiException.h.

105{ return new GaudiException( *this ); }
GaudiException(std::string Message, std::string Tag, StatusCode Code)
Constructor (1)

◆ code()

virtual const StatusCode & GaudiException::code ( ) const
inlinevirtual

StatusCode for Exception.

Definition at line 84 of file GaudiException.h.

84{ return m_code; }

◆ message()

virtual const std::string & GaudiException::message ( ) const
inlinevirtual

error message to be printed

Definition at line 66 of file GaudiException.h.

66{ return m_message; }

◆ operator=()

GaudiException & GaudiException::operator= ( const GaudiException & Exception)

assignment operator

Definition at line 59 of file GaudiException.cpp.

59 {
60 m_message = Exception.message();
61 m_tag = Exception.tag();
62 m_code = Exception.code();
63 m_backTrace = Exception.backTrace();
64 m_previous.reset( Exception.previous() ? Exception.previous()->clone() : nullptr );
65 return *this;
66}

◆ previous()

virtual GaudiException * GaudiException::previous ( ) const
inlinevirtual

get the previous exception ( "previous" element in the linked list)

Definition at line 93 of file GaudiException.h.

93{ return m_previous.get(); }

◆ printOut() [1/2]

MsgStream & GaudiException::printOut ( MsgStream & os) const
virtual

Output the exception to the Gaudi MsgStream.

Definition at line 74 of file GaudiException.cpp.

74 {
75 os << tag() << " \t " << message() << "\t StatusCode=" << code();
76 if ( !backTrace().empty() ) os << endmsg << "Exception stack trace\n" << backTrace();
77 return ( 0 != previous() ) ? previous()->printOut( os << endmsg ) : os;
78}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
virtual const std::string & message() const
error message to be printed
virtual const StatusCode & code() const
StatusCode for Exception.
virtual std::ostream & printOut(std::ostream &os=std::cerr) const
methods for overloaded printout to std::ostream& and MsgStream&
virtual const std::string & backTrace() const
return the stack trace at instantiation
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
virtual const std::string & tag() const
name tag for the exception, or exception type

◆ printOut() [2/2]

std::ostream & GaudiException::printOut ( std::ostream & os = std::cerr) const
virtual

methods for overloaded printout to std::ostream& and MsgStream&

Definition at line 68 of file GaudiException.cpp.

68 {
69 os << tag() << " \t " << message() << "\t StatusCode=" << code();
70 if ( !backTrace().empty() ) os << std::endl << "Exception stack trace\n" << backTrace();
71 return ( 0 != previous() ) ? previous()->printOut( os << std::endl ) : os;
72}

◆ setCode()

virtual const StatusCode & GaudiException::setCode ( const StatusCode & newStatus)
inlinevirtual

update the status code for the exception

Definition at line 87 of file GaudiException.h.

87 {
88 m_code = newStatus;
89 return code();
90 }

◆ setMessage()

virtual const std::string & GaudiException::setMessage ( const std::string & newMessage)
inlinevirtual

update the error message to be printed

Definition at line 69 of file GaudiException.h.

69 {
70 m_message = newMessage;
71 return message();
72 }

◆ setTag()

virtual const std::string & GaudiException::setTag ( const std::string & newTag)
inlinevirtual

update name tag

Definition at line 78 of file GaudiException.h.

78 {
79 m_tag = newTag;
80 return tag();
81 }

◆ tag()

virtual const std::string & GaudiException::tag ( ) const
inlinevirtual

name tag for the exception, or exception type

Definition at line 75 of file GaudiException.h.

75{ return m_tag; }

◆ what()

const char * GaudiException::what ( ) const
throw ( )
inlineoverride

method from std::exception

Definition at line 108 of file GaudiException.h.

108{ return message().c_str(); }

Friends And Related Symbol Documentation

◆ operator<< [1/4]

MsgStream & operator<< ( MsgStream & os,
const GaudiException & ge )
friend

overloaded printout to MsgStream

Definition at line 86 of file GaudiException.cpp.

86{ return ge.printOut( os ); }

◆ operator<< [2/4]

MsgStream & operator<< ( MsgStream & os,
const GaudiException * pge )
friend

overloaded printout to MsgStream

Definition at line 88 of file GaudiException.cpp.

88 {
89 return ( 0 == pge ) ? ( os << " GaudiException* points to NULL!" ) : ( os << *pge );
90}

◆ operator<< [3/4]

std::ostream & operator<< ( std::ostream & os,
const GaudiException & ge )
friend

overloaded printout to std::ostream

Definition at line 80 of file GaudiException.cpp.

80{ return ge.printOut( os ); }

◆ operator<< [4/4]

std::ostream & operator<< ( std::ostream & os,
const GaudiException * pge )
friend

overloaded printout to std::ostream

Definition at line 82 of file GaudiException.cpp.

82 {
83 return ( 0 == pge ) ? ( os << " GaudiException* points to NULL!" ) : ( os << *pge );
84}

◆ StatusCode

friend class StatusCode
friend

Definition at line 30 of file GaudiException.h.

Member Data Documentation

◆ m_backTrace

std::string GaudiException::m_backTrace
protected

status code for exception

Definition at line 126 of file GaudiException.h.

◆ m_code

StatusCode GaudiException::m_code
protected

exception tag

Definition at line 125 of file GaudiException.h.

◆ m_message

std::string GaudiException::m_message
protected

Definition at line 123 of file GaudiException.h.

◆ m_previous

std::unique_ptr<GaudiException> GaudiException::m_previous
protected

stack trace at instantiation

Definition at line 127 of file GaudiException.h.

◆ m_tag

std::string GaudiException::m_tag
protected

error message

Definition at line 124 of file GaudiException.h.

◆ s_proc

bool GaudiException::s_proc
staticprotected

"previous" element in the linked list

Definition at line 128 of file GaudiException.h.


The documentation for this class was generated from the following files: