blob: 3a4efd09254636698b084c87579e8fc740d4ba33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#include "cppunit/Exception.h"
namespace CppUnit {
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
/*!
* \deprecated Use SourceLine::isValid() instead.
*/
const std::string Exception::UNKNOWNFILENAME = "<unknown>";
/*!
* \deprecated Use SourceLine::isValid() instead.
*/
const long Exception::UNKNOWNLINENUMBER = -1;
#endif
/// Construct the exception
Exception::Exception( const Exception &other ) :
std::exception( other )
{
m_message = other.m_message;
m_sourceLine = other.m_sourceLine;
}
/*!
* \deprecated Use other constructor instead.
*/
Exception::Exception( std::string message,
SourceLine sourceLine ) :
m_message( message ),
m_sourceLine( sourceLine )
{
}
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
/*!
* \deprecated Use other constructor instead.
*/
Exception::Exception( std::string message,
long lineNumber,
std::string fileName ) :
m_message( message ),
m_sourceLine( fileName, lineNumber )
{
}
#endif
/// Destruct the exception
Exception::~Exception () throw()
{
}
/// Perform an assignment
Exception&
Exception::operator =( const Exception& other )
{
SuperClass::operator =(other);
if ( &other != this )
{
m_message = other.m_message;
m_sourceLine = other.m_sourceLine;
}
return *this;
}
/// Return descriptive message
const char*
Exception::what() const throw ()
{
return m_message.c_str ();
}
/// Location where the error occured
SourceLine
Exception::sourceLine() const
{
return m_sourceLine;
}
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
/// The line on which the error occurred
long
Exception::lineNumber() const
{
return m_sourceLine.isValid() ? m_sourceLine.lineNumber() :
UNKNOWNLINENUMBER;
}
/// The file in which the error occurred
std::string
Exception::fileName() const
{
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
UNKNOWNFILENAME;
}
#endif
Exception *
Exception::clone() const
{
return new Exception( *this );
}
bool
Exception::isInstanceOf( const Type &exceptionType ) const
{
return exceptionType == type();
}
Exception::Type
Exception::type()
{
return Type( "CppUnit::Exception" );
}
} // namespace CppUnit
|