Name

Exception

Description

The class Exception (see Figure C-4) is descended from std::exception. It contains a message describing the assertion failure and a SourceLine giving its location.

Exception contains a nested class named Exception::Type. The Type value represents the named Exception type, allowing runtime Exception type identification. For the base Exception class, the Type is CppUnit::Exception.

Exception belongs to the namespace CppUnit. It is declared in Exception.h and implemented in Exception.cpp.

The class Exception
Figure C-4. The class Exception

Declaration

class Exception : public std::exception

Constructors/Destructors

Exception(string message = "", SourceLine sourceLine = SourceLine( ))

A constructor for Exception. The message and sourceLine arguments have default empty values.

Exception(const Exception& other)

A copy constructor.

virtual ~Exception( ) throw( )

A destructor.

Public Methods

Exception& operator=(const Exception& other)

A copy operator.

virtual Exception *clone( ) const

Returns a copy of the Exception.

virtual bool isInstanceOf(const Type& type) const

Returns TRUE if the Exception is of the given Type. Used for runtime Exception type identification.

SourceLine sourceLine( ) const

Returns m_sourceLine.

static Type type( )

Returns CppUnit::Exception.

const char *what( ) const throw( )

Returns m_message as a C-style string.

Protected/Private Methods

None.

Attributes

string m_message ...

Get Unit Test Frameworks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.