CppUnit project page | FAQ

Exception.h
Go to the documentation of this file.
1 #ifndef CPPUNIT_EXCEPTION_H
2 #define CPPUNIT_EXCEPTION_H
3
4 #include <cppunit/Portability.h>
5 #include <cppunit/Message.h>
6 #include <cppunit/SourceLine.h>
7 #include <exception>
8
9
10 CPPUNIT_NS_BEGIN
11
12
19 class CPPUNIT_API Exception : public std::exception
20 {
21 public:
26 Exception( const Message &message = Message(),
27 const SourceLine &sourceLine = SourceLine() );
28
29 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
30
33 Exception( std::string message,
34 long lineNumber,
35 std::string fileName );
36 #endif
37
41 Exception( const Exception &other );
42
44 virtual ~Exception() throw();
45
47 Exception &operator =( const Exception &other );
48
50 const char *what() const throw();
51
53 SourceLine sourceLine() const;
54
56 Message message() const;
57
59 void setMessage( const Message &message );
60
61 #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
62 long lineNumber() const;
64
66 std::string fileName() const;
67
68 static const std::string UNKNOWNFILENAME;
69 static const long UNKNOWNLINENUMBER;
70 #endif
71
73 virtual Exception *clone() const;
74
75 protected:
76 // VC++ does not recognize call to parent class when prefixed
77 // with a namespace. This is a workaround.
78 typedef std::exception SuperClass;
79
80 Message m_message;
81 SourceLine m_sourceLine;
82 std::string m_whatMessage;
83 };
84
85
86 CPPUNIT_NS_END
87
88
89 #endif // CPPUNIT_EXCEPTION_H
90
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
Exception::SuperClass
std::exception SuperClass
Definition: Exception.h:78
SourceLine
Represents a source line location.
Definition: SourceLine.h:31
Exception::m_message
Message m_message
Definition: Exception.h:80
Exception::m_sourceLine
SourceLine m_sourceLine
Definition: Exception.h:81
Exception
Exceptions thrown by failed assertions.
Definition: Exception.h:20
Message
Message associated to an Exception.
Definition: Message.h:35
SourceLine.h
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:105
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:106
Exception::m_whatMessage
std::string m_whatMessage
Definition: Exception.h:82
Portability.h
Message.h

| Send comments to: CppUnit Developers