BasicException Class Reference

#include <BasicException.h>

Collaboration diagram for BasicException:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 BasicException ()
 BasicException (const std::string message)
 BasicException (const std::string message, const BasicFileLocation &location)
 BasicException (const std::string message, BasicException &cause)
 BasicException (const std::string message, const BasicFileLocation &location, BasicException &cause)
 BasicException (const BasicException &e)
 Copy constructor.
virtual ~BasicException ()
const std::string getMessage () const
BasicFileLocation getLocation () const
BasicSmartPointer< BasicExceptiongetCause () const
BasicSmartPointer< std::list
< std::string > > 
getTrace () const
std::ostream & print (std::ostream &stream, bool printLocations=true, unsigned int printLevel=0) const

Static Public Attributes

static unsigned int causePrintLevel = 10
static bool enableStackTraces = false

Protected Member Functions

void init ()

Private Attributes

std::string message
BasicFileLocation location
BasicSmartPointer< BasicExceptioncause
BasicSmartPointer< std::list
< std::string > > 
trace

Friends

std::ostream & operator<< (std::ostream &, const BasicException &)


Detailed Description

BasicException is a general purpose exception class. It is similar to the java Exception class. A BasicException can carry a message, a BasicFileLocation and/or a pointer to an exception which was the original cause.

There are preprocessor macros that can be used to as a convient way to add the current file, line and column where the exception occured. These are:

THROW(const string message)

and

ASSERT_OR_THROW(const string message, const bool condition)

The latter can be used to in place of assert(const bool condition). Throwing an exception instead of aborting overcomes some of the limitations of the standard assert.

Definition at line 61 of file BasicException.h.


Constructor & Destructor Documentation

BasicException::BasicException (  )  [inline]

Definition at line 71 of file BasicException.h.

References init().

Referenced by BasicException().

BasicException::BasicException ( const std::string  message  )  [inline]

Definition at line 73 of file BasicException.h.

References init().

BasicException::BasicException ( const std::string  message,
const BasicFileLocation location 
) [inline]

Definition at line 77 of file BasicException.h.

References init().

BasicException::BasicException ( const std::string  message,
BasicException cause 
) [inline]

Definition at line 82 of file BasicException.h.

References BasicException(), and init().

BasicException::BasicException ( const std::string  message,
const BasicFileLocation location,
BasicException cause 
) [inline]

Definition at line 88 of file BasicException.h.

References BasicException(), and init().

BasicException::BasicException ( const BasicException e  )  [inline]

Copy constructor.

Definition at line 96 of file BasicException.h.

virtual BasicException::~BasicException (  )  [inline, virtual]

Definition at line 99 of file BasicException.h.


Member Function Documentation

const std::string BasicException::getMessage (  )  const [inline]

Definition at line 101 of file BasicException.h.

References message.

Referenced by CC3DTransaction::simulationThreadPython().

BasicFileLocation BasicException::getLocation (  )  const [inline]

Definition at line 102 of file BasicException.h.

References location.

Referenced by CC3DTransaction::simulationThreadPython().

BasicSmartPointer<BasicException> BasicException::getCause (  )  const [inline]

Returns:
A BasicSmartPointer to the BasicException that caused this exception or NULL.

Definition at line 108 of file BasicException.h.

References cause.

BasicSmartPointer<std::list<std::string> > BasicException::getTrace (  )  const [inline]

Definition at line 110 of file BasicException.h.

References trace.

std::ostream& BasicException::print ( std::ostream &  stream,
bool  printLocations = true,
unsigned int  printLevel = 0 
) const [inline]

Prints the complete exception recuring down to the cause exception if not null. WARNING: If there are many layers of causes this function could print a very large amount of data. This can be limited by setting the causePrintLevel variable.

Parameters:
stream The output stream.
printLocations Print file locations.
printLevel The current cause print level.
Returns:
A reference to the passed stream.

Definition at line 124 of file BasicException.h.

References cause, causePrintLevel, enableStackTraces, BasicFileLocation::isEmpty(), BasicSmartPointer< T, alloc_t >::isNull(), location, message, and trace.

Referenced by operator<<().

void BasicException::init (  )  [inline, protected]

Definition at line 156 of file BasicException.h.

References enableStackTraces, and trace.

Referenced by BasicException().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const BasicException e 
) [friend]

An stream output operator for BasicException. This allows you to print the text of an exception to a stream like so:

. . . } catch (BasicException &e) { cout << e << endl; return 0; }

Definition at line 181 of file BasicException.h.


Member Data Documentation

std::string BasicException::message [private]

Definition at line 62 of file BasicException.h.

Referenced by getMessage(), and print().

Definition at line 63 of file BasicException.h.

Referenced by getLocation(), and print().

Definition at line 64 of file BasicException.h.

Referenced by getCause(), and print().

BasicSmartPointer<std::list<std::string> > BasicException::trace [private]

Definition at line 65 of file BasicException.h.

Referenced by getTrace(), init(), and print().

unsigned int BasicException::causePrintLevel = 10 [static]

Definition at line 68 of file BasicException.h.

Referenced by print().

bool BasicException::enableStackTraces = false [static]

Definition at line 69 of file BasicException.h.

Referenced by init(), and print().


The documentation for this class was generated from the following files:

Generated on Thu Dec 4 11:41:19 2008 for CompuCell3D by  doxygen 1.5.6