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.
Declaration
class Exception : public std::exception
Constructors/Destructors
-
Exception(string message = "", SourceLine sourceLine = SourceLine( ))
A constructor for
Exception
. Themessage
andsourceLine
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 theException
is of the givenType
. Used for runtimeException
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.