1
#include <cppunit/Exception.h>
7
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
9
* \deprecated Use SourceLine::isValid() instead.
11
const std::string Exception::UNKNOWNFILENAME = "<unknown>";
14
* \deprecated Use SourceLine::isValid() instead.
16
const long Exception::UNKNOWNLINENUMBER = -1;
20
Exception::Exception( const Exception &other )
21
: std::exception( other )
23
m_message = other.m_message;
24
m_sourceLine = other.m_sourceLine;
28
Exception::Exception( const Message &message,
29
const SourceLine &sourceLine )
30
: m_message( message )
31
, m_sourceLine( sourceLine )
36
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
37
Exception::Exception( std::string message,
39
std::string fileName )
40
: m_message( message )
41
, m_sourceLine( fileName, lineNumber )
47
Exception::~Exception() throw()
53
Exception::operator =( const Exception& other )
55
// Don't call superclass operator =(). VC++ STL implementation
56
// has a bug. It calls the destructor and copy constructor of
57
// std::exception() which reset the virtual table to std::exception.
58
// SuperClass::operator =(other);
62
m_message = other.m_message;
63
m_sourceLine = other.m_sourceLine;
71
Exception::what() const throw()
73
Exception *mutableThis = CPPUNIT_CONST_CAST( Exception *, this );
74
mutableThis->m_whatMessage = m_message.shortDescription() + "\n" +
76
return m_whatMessage.c_str();
81
Exception::sourceLine() const
88
Exception::message() const
95
Exception::setMessage( const Message &message )
101
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
103
Exception::lineNumber() const
105
return m_sourceLine.isValid() ? m_sourceLine.lineNumber() :
111
Exception::fileName() const
113
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
120
Exception::clone() const
122
return new Exception( *this );