The Gaudi Framework  master (37c0b60a)
GaudiException.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_GAUDIEXCEPTION_H
12 #define GAUDIKERNEL_GAUDIEXCEPTION_H
13 
14 // Include files
15 #include <GaudiKernel/Kernel.h>
16 #include <GaudiKernel/MsgStream.h>
17 #include <GaudiKernel/StatusCode.h>
18 
19 #include <exception>
20 #include <iostream>
21 #include <string>
22 
31 class GAUDI_API GaudiException : virtual public std::exception {
32  friend class StatusCode;
33 
34 public:
41 
49 
57 
59  GaudiException( const GaudiException& Exception );
60 
62  virtual ~GaudiException() throw();
63 
65  GaudiException& operator=( const GaudiException& Exception );
66 
68  virtual const std::string& message() const { return m_message; }
69 
71  virtual const std::string& setMessage( const std::string& newMessage ) {
72  m_message = newMessage;
73  return message();
74  }
75 
77  virtual const std::string& tag() const { return m_tag; }
78 
80  virtual const std::string& setTag( const std::string& newTag ) {
81  m_tag = newTag;
82  return tag();
83  }
84 
86  virtual const StatusCode& code() const { return m_code; }
87 
89  virtual const StatusCode& setCode( const StatusCode& newStatus ) {
90  m_code = newStatus;
91  return code();
92  }
93 
95  virtual GaudiException* previous() const { return m_previous.get(); }
96 
98  virtual const std::string& backTrace() const { return m_backTrace; }
99 
101  virtual std::ostream& printOut( std::ostream& os = std::cerr ) const;
102 
104  virtual MsgStream& printOut( MsgStream& os ) const;
105 
107  virtual GaudiException* clone() const { return new GaudiException( *this ); }
108 
110  const char* what() const throw() override { return message().c_str(); }
111 
113  friend std::ostream& operator<<( std::ostream& os, const GaudiException& ge );
114 
116  friend std::ostream& operator<<( std::ostream& os, const GaudiException* pge );
117 
119  friend MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
120 
122  friend MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
123 
124 protected:
130  static bool s_proc;
131 };
132 
133 #endif // GAUDIKERNEL_GAUDIEXCEPTION_H
precedence.message
message
Definition: precedence.py:19
std::string
STL class.
std::exception
STL class.
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:130
GaudiException::setMessage
virtual const std::string & setMessage(const std::string &newMessage)
update the error message to be printed
Definition: GaudiException.h:71
GaudiException
Definition: GaudiException.h:31
GaudiException::m_previous
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation
Definition: GaudiException.h:129
GaudiException::previous
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
Definition: GaudiException.h:95
StatusCode::m_code
code_t m_code
The status code value.
Definition: StatusCode.h:260
std::operator<<
ostream & operator<<(ostream &s, const MyCustomType &m)
Definition: CustomPropertiesAlg.cpp:47
GaudiException::setCode
virtual const StatusCode & setCode(const StatusCode &newStatus)
update the status code for the exception
Definition: GaudiException.h:89
StatusCode.h
GaudiException::m_message
std::string m_message
Definition: GaudiException.h:125
GaudiException::backTrace
virtual const std::string & backTrace() const
return the stack trace at instantiation
Definition: GaudiException.h:98
StatusCode
Definition: StatusCode.h:65
Message
Definition: Message.h:26
std::ostream
STL class.
GaudiException::setTag
virtual const std::string & setTag(const std::string &newTag)
update name tag
Definition: GaudiException.h:80
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:77
GaudiException::m_backTrace
std::string m_backTrace
status code for exception
Definition: GaudiException.h:128
GaudiException::m_tag
std::string m_tag
error message
Definition: GaudiException.h:126
MsgStream
Definition: MsgStream.h:33
GaudiException::clone
virtual GaudiException * clone() const
clone operation
Definition: GaudiException.h:107
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:86
std
STL namespace.
Kernel.h
std::unique_ptr< GaudiException >
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
GaudiException::what
const char * what() const override
method from std::exception
Definition: GaudiException.h:110
MsgStream.h
GaudiException::m_code
StatusCode m_code
exception tag
Definition: GaudiException.h:127