The Gaudi Framework  v33r0 (d5ea422b)
GaudiException.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 
112 protected:
118  static bool s_proc;
119 };
120 
123 
126 
128 MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
129 
131 MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
132 
133 #endif // GAUDIKERNEL_GAUDIEXCEPTION_H
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
Define general base for Gaudi exception.
virtual GaudiException * previous() const
get the previous exception ( "previous" element in the linked list)
virtual const StatusCode & setCode(const StatusCode &newStatus)
update the status code for the exception
code_t m_code
The status code value.
Definition: StatusCode.h:304
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
virtual const std::string & tag() const
name tag for the exception, or exception type
STL namespace.
std::ostream & operator<<(std::ostream &os, const GaudiException &ge)
overloaded printout to std::ostream
std::string m_tag
error message
STL class.
const char * what() const override
method from std::exception
std::string m_message
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
STL class.
std::string message() const
Description (or name) of StatusCode value.
Definition: StatusCode.h:248
virtual const StatusCode & code() const
StatusCode for Exception.
The Message class.
Definition: Message.h:27
virtual GaudiException * clone() const
clone operation
std::string m_backTrace
status code for exception
virtual const std::string & backTrace() const
return the stack trace at instantiation
virtual const std::string & setTag(const std::string &newTag)
update name tag
T c_str(T... args)
StatusCode m_code
exception tag
#define GAUDI_API
Definition: Kernel.h:81
STL class.
std::unique_ptr< GaudiException > m_previous
stack trace at instantiation