# BasicException Class Reference

BasicException is a general purpose exception class. More...

`#include <BasicException.h>`

Collaboration diagram for BasicException:

[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< BasicException > | getCause () const
BasicSmartPointer< std::list< std::string > > | getTrace () const
std::ostream & | print (std::ostream &stream, bool printLocations=true, unsigned int printLevel=0) const
| Prints the complete exception recuring down to the cause exception if not null.

## Static Public Attributes

unsigned int | causePrintLevel = 10
bool | enableStackTraces = false

## Protected Member Functions

void | init ()

## Private Attributes

std::string | message
BasicFileLocation | location
BasicSmartPointer< BasicException > | cause
BasicSmartPointer< std::list< std::string > > | trace

## Friends

std::ostream & | operator<< (std::ostream &, const BasicException &)
| An stream output operator for 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.

## Constructor & Destructor Documentation

BasicException::BasicException | ( |  | ) | `[inline]`

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

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

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

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

BasicException::BasicException | ( | const BasicException & | e | ) | `[inline]`

| Copy constructor.

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

## Member Function Documentation

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

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

BasicFileLocation BasicException::getLocation | ( |  | ) | const`[inline]`

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

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

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

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.

## 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; }

## Member Data Documentation

BasicSmartPointer<BasicException> BasicException::cause `[private]`

unsigned int BasicException::causePrintLevel = 10`[static]`

bool BasicException::enableStackTraces = false`[static]`

BasicFileLocation BasicException::location `[private]`

std::string BasicException::message `[private]`

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

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

- BasicException.h
- BasicException.cpp