Exception base class.
More...
#include <OpenMS/CONCEPT/Exception.h>
Inherits runtime_error.
Inherited by ClusterFunctor::InsufficientInput, BufferOverflow, ConversionError, DepletedIDPool, DivisionByZero, ElementNotFound, FailedAPICall, FileEmpty, FileNameTooLong, FileNotFound, FileNotReadable, FileNotWritable, IOException, IllegalArgument, IllegalPosition, IllegalSelfOperation, IllegalTreeOperation, IncompatibleIterators, IndexOverflow, IndexUnderflow, InternalToolError, InvalidFileType, InvalidIterator, InvalidParameter, InvalidRange, InvalidSize, InvalidValue, MissingInformation, NotImplemented, NotSorted, NullPointer, OutOfGrid, OutOfMemory, OutOfRange, ParseError, Postcondition, Precondition, RequiredParameterNotGiven, SizeUnderflow, SqlOperationFailed, UnableToCalibrate, UnableToCreateFile, UnableToFit, UnregisteredParameter, WrongParameterType, FeatureFinderDefs::NoSuccessor, FeatureFinderDefs::NoSuccessor, XMLHandler::EndParsingSoftly, and UnnormalizedComparator.
|
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...
|
|
const char * | getName () const noexcept |
| Returns the name of the exception. More...
|
|
int | getLine () const noexcept |
| Returns the line number where it occurred. More...
|
|
const char * | getFile () const noexcept |
| Returns the file where it occurred. More...
|
|
const char * | getFunction () const noexcept |
| Returns the function where it occurred. More...
|
|
const char * | getMessage () const noexcept |
| Returns the message. More...
|
|
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__, OPENMS_PRETTY_FUNCTION,...);
FILE and LINE are built-in preprocessor macros that hold the desired information.
OPENMS_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.
◆ BaseException() [1/4]
◆ BaseException() [2/4]
BaseException |
( |
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
function |
|
) |
| |
|
noexcept |
◆ BaseException() [3/4]
BaseException |
( |
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
function, |
|
|
const std::string & |
name, |
|
|
const std::string & |
message |
|
) |
| |
|
noexcept |
◆ BaseException() [4/4]
◆ ~BaseException()
◆ getFile()
const char* getFile |
( |
| ) |
const |
|
noexcept |
Returns the file where it occurred.
Referenced by main().
◆ getFunction()
const char* getFunction |
( |
| ) |
const |
|
noexcept |
Returns the function where it occurred.
◆ getLine()
Returns the line number where it occurred.
Referenced by main().
◆ getMessage()
const char* getMessage |
( |
| ) |
const |
|
noexcept |
◆ getName()
const char* getName |
( |
| ) |
const |
|
noexcept |
◆ file_
The source file the exception was thrown in.
◆ function_
The source file the exception was thrown in.
◆ line_
The line number the exception was thrown in.
◆ name_
The name of the exception.