#include "cppunit/Exception.h"
namespace CppUnit {
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
const string Exception::UNKNOWNFILENAME = "<unknown>";
const long Exception::UNKNOWNLINENUMBER = -1;
#endif
Exception::Exception( const Exception &other ) :
exception( other )
{
m_message = other.m_message;
m_sourceLine = other.m_sourceLine;
}
Exception::Exception( std::string message,
SourceLine sourceLine ) :
m_message( message ),
m_sourceLine( sourceLine )
{
}
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
Exception::Exception( std::string message,
long lineNumber,
std::string fileName ) :
m_message( message ),
m_sourceLine( fileName, lineNumber )
{
}
#endif
Exception::~Exception () throw()
{
}
Exception&
Exception::operator =( const Exception& other )
{
if ( &other != this )
{
m_message = other.m_message;
m_sourceLine = other.m_sourceLine;
}
return *this;
}
const char*
Exception::what() const throw()
{
return m_message.c_str ();
}
SourceLine
Exception::sourceLine() const
{
return m_sourceLine;
}
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
long
Exception::lineNumber() const
{
return m_sourceLine.isValid() ? m_sourceLine.lineNumber() :
UNKNOWNLINENUMBER;
}
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" );
}
}