Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

Exception::GeneralException Class Reference
[Common Definitions]

General exception class. More...

#include <exception.h>

Inheritance diagram for Exception::GeneralException:

Bit::IllegalOperation Bond::NotBound Client::InvalidClient Client::NoPersistentObject EnumeratorIndex::IncompatibleIndex Exception::BufferOverflow Exception::DivisionByZero Exception::FileNotFound Exception::IllegalPosition Exception::IllegalSelfOperation Exception::IllegalTreeOperation Exception::IncompatibleIterators Exception::IndexOverflow Exception::IndexUnderflow Exception::InvalidFormat Exception::InvalidIterator Exception::InvalidOption Exception::InvalidRange Exception::InvalidSize Exception::NotImplemented Exception::NullPointer Exception::OutOfGrid Exception::OutOfMemory Exception::OutOfRange Exception::ParseError Exception::Postcondition Exception::Precondition Exception::SizeUnderflow Exception::TooManyBonds Exception::TooManyErrors File::CannotWrite FragmentDB::NoFragmentNode HashMap< Key, T >::IllegalKey HashSet< Key >::IllegalKey Substring::InvalidSubstring Substring::UnboundSubstring TCPTransfer::TransferFailed VIEW::ColorUnit::NotInHexFormat VIEW::GLDisplayList::DisplayListRedeclaration VIEW::GLDisplayList::NestedDisplayList VIEW::GLDisplayList::NoDisplayListAvailable VIEW::GLRenderer::WrongModes VIEW::Server::NotCompositeObject List of all members.

Public Member Functions

Constructors and Destructors
 GeneralException () throw ()
 Default constructor.
 GeneralException (const char *file, int line) throw ()
 Constructor.
 GeneralException (const char *file, int line, const String &name, const String &message) throw ()
 Constructor.
 GeneralException (const GeneralException &exception) throw ()
 Copy constructor.
virtual ~GeneralException () throw ()
 Destructor.
Accessors
const char * getName () const throw ()
 Returns the name of the exception.
const char * getMessage () const throw ()
 Returns the error message of the exception.
void setMessage (const std::string &message) throw ()
 Modify the exception's error message.
int getLine () const throw ()
 Returns the line number where it occured.
const char * getFile () const throw ()
 Returns the file where it occured.

Protected Attributes

const char * file_
int line_
std::string name_
std::string message_

Detailed Description

General exception class.

This class is intended as a base class for all other exceptions. Each exception class should define a constructor taking a string and an int as parameters. These two values are interpreted as the current filename and line number and is usually printed in case of an uncaught exception. To support this feature, each throw directive should look as follows:

throw Exception::GeneralException(__FILE__, __LINE__);
__FILE__ and __LINE__ are built-in preprocessor macros that hold the desired information.
BALL provides its own terminate handler. This handler extracts as much information as possible from the exception, prints it to cerr and Log , and finally calls exits the program cleanly (with exit code 1). This can be rather inconvenient for debugging, since you are told where the exception was thrown, but in general you do not know anything about the context. Therefore terminate can also create a core dump. Using a debugger (e.g. dbx or gdb) you can then create a stack traceback. To create a core dump, you should set the environment variable BALL_DUMP_CORE to any (non empty) value.