Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

Base Class Reference
[Exceptions]

#include <OpenMS/CONCEPT/Exception.h>

Inheritance diagram for Base:

DBConnection::InvalidQuery DBConnection::NotConnected BufferOverflow ConversionError DivisionByZero ElementNotFound FileEmpty FileNotFound FileNotReadable IllegalArgument IllegalPosition IllegalSelfOperation IllegalTreeOperation IncompatibleIterators IndexOverflow IndexUnderflow InvalidIterator InvalidParameter InvalidRange InvalidSize InvalidValue MissingInformation NotImplemented NullPointer OutOfGrid OutOfMemory OutOfRange ParseError Postcondition Precondition RequiredParameterNotGiven SizeUnderflow UnableToCreateFile UnregisteredParameter WrongParameterType FeatureFinderDefs::NoSuccessor FeatureFinderDefs::UnableToFit HashMap::IllegalKey XMLHandler::EndParsingSoftly TOFCalibration::UnableToCalibrate

List of all members.


Detailed Description

Exception base 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::Exception(__FILE__, __LINE__,
      __PRETTY_FUNCTION__); 
Remember that __FILE__ and __LINE__ are built-in preprocessor macros that hold the desired information. __PRETTY_FUNCTION__ is replaced by the GNU G++ compiler with the demangled name of the current function. (For other compilers it is defined as "<unknown>" in config.h.)

OpenMS provides its own Exception::GlobalExceptionHandler::terminate() handler. This handler extracts as much information as possible from the exception, prints it to cerr, 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 OPENMS_DUMP_CORE to any (non empty) value.

Public Member Functions

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

Protected Attributes

const char * file_
 The source file the exception was thrown in.
int line_
 The line number the exception was thrown in.
const char * function_
 The source file the exception was thrown in.
std::string name_
 The name of the exception.
std::string what_
 A more detailed description of the exception's cause.


Constructor & Destructor Documentation

Base (  )  throw ()

Default constructor.

Base ( const char *  file,
int  line,
const char *  function 
) throw ()

Constructor.

Base ( const char *  file,
int  line,
const char *  function,
const std::string &  name,
const std::string &  message 
) throw ()

Constructor.

Base ( const Base exception  )  throw ()

Copy constructor.

virtual ~Base (  )  throw () [virtual]

Destructor.


Member Function Documentation

const char* getName (  )  const throw ()

Returns the name of the exception.

virtual const char* what (  )  const throw () [virtual]

Returns the error message of the exception.

int getLine (  )  const throw ()

Returns the line number where it occured.

const char* getFile (  )  const throw ()

Returns the file where it occured.

const char* getFunction (  )  const throw ()

Returns the function where it occured.

const char* getMessage (  )  const throw ()

Returns the message.

void setMessage ( const std::string &  message  )  throw ()

Modify the exception's error message.


Member Data Documentation

const char* file_ [protected]

The source file the exception was thrown in.

int line_ [protected]

The line number the exception was thrown in.

const char* function_ [protected]

The source file the exception was thrown in.

std::string name_ [protected]

The name of the exception.

std::string what_ [protected]

A more detailed description of the exception's cause.


The documentation for this class was generated from the following file:
Generated Tue Apr 1 15:36:49 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1