Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiException.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 <memory>
21 #include <ostream>
22 #include <string>
23 
32 class GAUDI_API GaudiException : virtual public std::exception {
33  friend class StatusCode;
34 
35 public:
42 
50 
58 
60  GaudiException( const GaudiException& Exception );
61 
63  virtual ~GaudiException() throw();
64 
66  GaudiException& operator=( const GaudiException& Exception );
67 
69  virtual const std::string& message() const { return m_message; }
70 
72  virtual const std::string& setMessage( const std::string& newMessage ) {
73  m_message = newMessage;
74  return message();
75  }
76 
78  virtual const std::string& tag() const { return m_tag; }
79 
81  virtual const std::string& setTag( const std::string& newTag ) {
82  m_tag = newTag;
83  return tag();
84  }
85 
87  virtual const StatusCode& code() const { return m_code; }
88 
90  virtual const StatusCode& setCode( const StatusCode& newStatus ) {
91  m_code = newStatus;
92  return code();
93  }
94 
96  virtual GaudiException* previous() const { return m_previous.get(); }
97 
99  virtual const std::string& backTrace() const { return m_backTrace; }
100 
102  virtual std::ostream& printOut( std::ostream& os = std::cerr ) const;
103 
105  virtual MsgStream& printOut( MsgStream& os ) const;
106 
108  virtual GaudiException* clone() const { return new GaudiException( *this ); }
109 
111  const char* what() const throw() override { return message().c_str(); }
112 
114  friend std::ostream& operator<<( std::ostream& os, const GaudiException& ge );
115 
117  friend std::ostream& operator<<( std::ostream& os, const GaudiException* pge );
118 
120  friend MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
121 
123  friend MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
124 
125 protected:
131  static bool s_proc;
132 };
133 
134 #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:131
GaudiException::setMessage
virtual const std::string & setMessage(const std::string &newMessage)
update the error message to be printed
Definition: GaudiException.h:72
GaudiException
Definition: GaudiException.h:32
GaudiException::m_previous
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation
Definition: GaudiException.h:130
GaudiException::previous
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
Definition: GaudiException.h:96
StatusCode::m_code
code_t m_code
The status code value.
Definition: StatusCode.h:261
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:90
StatusCode.h
GaudiException::m_message
std::string m_message
Definition: GaudiException.h:126
GaudiException::backTrace
virtual const std::string & backTrace() const
return the stack trace at instantiation
Definition: GaudiException.h:99
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:81
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:78
GaudiException::m_backTrace
std::string m_backTrace
status code for exception
Definition: GaudiException.h:129
GaudiException::m_tag
std::string m_tag
error message
Definition: GaudiException.h:127
MsgStream
Definition: MsgStream.h:33
GaudiException::clone
virtual GaudiException * clone() const
clone operation
Definition: GaudiException.h:108
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:87
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:111
MsgStream.h
GaudiException::m_code
StatusCode m_code
exception tag
Definition: GaudiException.h:128