File indexing completed on 2025-01-18 09:57:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_GAUDIEXCEPTION_H
0012 #define GAUDIKERNEL_GAUDIEXCEPTION_H
0013
0014
0015 #include "GaudiKernel/Kernel.h"
0016 #include "GaudiKernel/MsgStream.h"
0017 #include "GaudiKernel/StatusCode.h"
0018
0019 #include <exception>
0020 #include <iostream>
0021 #include <string>
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class GAUDI_API GaudiException : virtual public std::exception {
0032 friend class StatusCode;
0033
0034 public:
0035
0036
0037
0038
0039
0040 GaudiException( std::string Message, std::string Tag, StatusCode Code );
0041
0042
0043
0044
0045
0046
0047
0048 GaudiException( std::string Message, std::string Tag, StatusCode Code, const GaudiException& Exception );
0049
0050
0051
0052
0053
0054
0055
0056 GaudiException( std::string Message, std::string Tag, StatusCode Code, const std::exception& Exception );
0057
0058
0059 GaudiException( const GaudiException& Exception );
0060
0061
0062 virtual ~GaudiException() throw();
0063
0064
0065 GaudiException& operator=( const GaudiException& Exception );
0066
0067
0068 virtual const std::string& message() const { return m_message; }
0069
0070
0071 virtual const std::string& setMessage( const std::string& newMessage ) {
0072 m_message = newMessage;
0073 return message();
0074 }
0075
0076
0077 virtual const std::string& tag() const { return m_tag; }
0078
0079
0080 virtual const std::string& setTag( const std::string& newTag ) {
0081 m_tag = newTag;
0082 return tag();
0083 }
0084
0085
0086 virtual const StatusCode& code() const { return m_code; }
0087
0088
0089 virtual const StatusCode& setCode( const StatusCode& newStatus ) {
0090 m_code = newStatus;
0091 return code();
0092 }
0093
0094
0095 virtual GaudiException* previous() const { return m_previous.get(); }
0096
0097
0098 virtual const std::string& backTrace() const { return m_backTrace; }
0099
0100
0101 virtual std::ostream& printOut( std::ostream& os = std::cerr ) const;
0102
0103
0104 virtual MsgStream& printOut( MsgStream& os ) const;
0105
0106
0107 virtual GaudiException* clone() const { return new GaudiException( *this ); }
0108
0109
0110 const char* what() const throw() override { return message().c_str(); }
0111
0112 protected:
0113 std::string m_message;
0114 std::string m_tag;
0115 StatusCode m_code;
0116 std::string m_backTrace;
0117 std::unique_ptr<GaudiException> m_previous;
0118 static bool s_proc;
0119 };
0120
0121
0122 std::ostream& operator<<( std::ostream& os, const GaudiException& ge );
0123
0124
0125 std::ostream& operator<<( std::ostream& os, const GaudiException* pge );
0126
0127
0128 MsgStream& operator<<( MsgStream& os, const GaudiException& ge );
0129
0130
0131 MsgStream& operator<<( MsgStream& os, const GaudiException* pge );
0132
0133 #endif