Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCExcept Class Reference

Base class for all library generated exceptions. More...

#include <mcllib/MCExcept.h>

Inheritance diagram for MCExcept:

MCDBExcept MCExceptFatal MCInterrupt MCTimedOut List of all members.

Public Member Functions

const MCSrcMsggetMsg () const
 Get the contained source message (where the exception originated).
 MCExcept (const char *exStr)
 Construct from a C-style string.
 MCExcept (const MCSrcMsg &msg)
 Construct from a source message.
virtual const char * what () const throw ()
 Method to get the text which describes the exception.
virtual ~MCExcept () throw ()
 Virtual destructor from std::exception.

Protected Member Functions

void complete (const MCStringStream &mcss)
 Construct the complete exception message.
 MCExcept ()
 Construct an exception with no message.
virtual void prefix (MCStringStream &mcss)
 Prepend any prefix required by a derived exception to mcss.
void setFileLine (const char *file, MCSrcMsg::linenum_t line)
 Set source file and line.
virtual void suffix (MCStringStream &mcss)
 Append any suffix required by a derived exception to mcss.

Detailed Description

Base class for all library generated exceptions.

Because it is derived from std::exception, an application can catch std::exception and all library generated and system generated exceptions will be caught. If MCExcept is thrown (as opposed to MCFatalExcept), the exception is not considered by the library to be worthy of causing application termination. User-readable messages can be obtained from exceptions by calling the what() method. To allow extensions and various message manipulations, derived classes can add a prefix and/or a suffix to the original message text by over-riding the prefix() and suffix() methods.

Constructor & Destructor Documentation

MCExcept const MCSrcMsg msg  ) 

Construct from a source message.

Source messages are messages in the library source and indicate the file and line at which the exception occured, the exception severity etc. Using MCThrow("...") will invoke this constructor with the correct MCSrcMsg containing the file and line information.

msg an MCSrcMsg object to obtain file and line information from and the message details.

MCExcept const char *  exStr  ) 

Construct from a C-style string.

In this case an MCSrcMsg is created without file and line information.

exStr the exception that has occured.

Member Function Documentation

void complete const MCStringStream mcss  )  [protected]

Construct the complete exception message.

This method constructs the complete message from prefix() + original_text + mcss + suffix()

const MCSrcMsg& getMsg  )  const

Get the contained source message (where the exception originated).

the MCSrcMsg used to construct the exception

Generated on Wed Jan 12 19:05:49 2005 for MCLLIB by  doxygen