Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Protected Attributes | List of all members
BaseException Class Reference

Exception base class. More...

#include <OpenMS/CONCEPT/Exception.h>

Inheritance diagram for BaseException:
BinnedSpectrum::NoSpectrumIntegrated BinnedSpectrumCompareFunctor::IncompatibleBinning ClusterFunctor::InsufficientInput BufferOverflow ConversionError DepletedIDPool DivisionByZero ElementNotFound FailedAPICall FileEmpty FileNotFound FileNotReadable FileNotWritable IllegalArgument IllegalPosition IllegalSelfOperation IllegalTreeOperation IncompatibleIterators IndexOverflow IndexUnderflow InvalidIterator InvalidParameter InvalidRange InvalidSize InvalidValue IOException MissingInformation NotImplemented NullPointer OutOfGrid OutOfMemory OutOfRange ParseError Postcondition Precondition RequiredParameterNotGiven SizeUnderflow UnableToCalibrate UnableToCreateFile UnableToFit UnregisteredParameter WrongParameterType FeatureFinderDefs::NoSuccessor XMLHandler::EndParsingSoftly Map< Key, T >::IllegalKey UnnormalizedComparator

Public Member Functions

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

Protected Attributes

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

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 filename (string), line (int) and function name (string) as first arguments. This information 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__,...);

__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.

Constructor & Destructor Documentation

BaseException ( )
throw (
)

Default constructor.

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

Constructor.

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

Constructor.

BaseException ( const BaseException exception)
throw (
)

Copy constructor.

virtual ~BaseException ( )
throw (
)
virtual

Destructor.

Member Function Documentation

const char* getFile ( ) const
throw (
)

Returns the file where it occurred.

Referenced by main().

const char* getFunction ( ) const
throw (
)

Returns the function where it occurred.

int getLine ( ) const
throw (
)

Returns the line number where it occurred.

Referenced by main().

const char* getMessage ( ) const
throw (
)

Returns the message.

Referenced by QApplicationTOPP::notify().

const char* getName ( ) const
throw (
)

Returns the name of the exception.

Referenced by QApplicationTOPP::notify().

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

Modify the exception's error message.

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

Member Data Documentation

const char* file_
protected

The source file the exception was thrown in.

const char* function_
protected

The source file the exception was thrown in.

int line_
protected

The line number 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.


OpenMS / TOPP release 2.0.0 Documentation generated on Thu Aug 20 2015 01:44:42 using doxygen 1.8.9.1