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
Exception
Exceptions thrown by failed assertions.Exception is an exception that serves descriptive strings thro...
Definition: Exception.h:19
Portability.h
Exception::m_whatMessage
std::string m_whatMessage
Definition: Exception.h:82
SourceLine
Represents a source line location.Used to capture the failure location in assertion.
Definition: SourceLine.h:30
CPPUNIT_NS_END
#define CPPUNIT_NS_END
Definition: Portability.h:120
CPPUNIT_NS_BEGIN
#define CPPUNIT_NS_BEGIN
Definition: Portability.h:119
Exception::m_sourceLine
SourceLine m_sourceLine
Definition: Exception.h:81
SourceLine.h
Message
Message associated to an Exception.A message is composed of two items:
Definition: Message.h:38
Exception::m_message
Message m_message
Definition: Exception.h:80
Exception::SuperClass
std::exception SuperClass
Definition: Exception.h:78
CPPUNIT_API
#define CPPUNIT_API
Definition: CppUnitApi.h:27
Message.h

| Send comments to: CppUnit Developers