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. ThemessageandsourceLinearguments 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
TRUEif theExceptionis of the givenType. Used for runtimeExceptiontype identification.-
SourceLine sourceLine( ) const Returns
m_sourceLine.-
static Type type( ) Returns
CppUnit::Exception.-
const char *what( ) const throw( ) Returns
m_messageas a C-style string.
Protected/Private Methods
None.
Attributes
-
string m_message ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
