#include <exception>
#include <iostream>
#include <sstream>
#include <string>
#include "b2ppconfig.h"
#include "utils/b2util.H"
Go to the source code of this file.
Classes | |
class | b2000::Exception |
struct | b2000::Exception::Throw |
struct | b2000::Exception::Warning |
class | b2000::GenericException< NAME > |
Namespaces | |
namespace | b2000 |
Contains the base classes for implementing Finite Elements. | |
Macros | |
#define | THROW Exception::Throw(__FILE__, __LINE__) |
Typedefs | |
typedef GenericException< UnimplementedError_name > | b2000::UnimplementedError |
typedef GenericException< KeyError_name > | b2000::KeyError |
typedef GenericException< TypeError_name > | b2000::TypeError |
typedef GenericException< ValueError_name > | b2000::ValueError |
typedef GenericException< IOError_name > | b2000::IOError |
typedef GenericException< DBError_name > | b2000::DBError |
typedef GenericException< SizeError_name > | b2000::SizeError |
typedef GenericException< SystemError_name > | b2000::LoggingError |
typedef GenericException< PythonError_name > | b2000::PythonError |
A set of C++ exception classes for convenient error reporting and handling, with (if supported by the platform) support for backtraces.
In contrast to Fortran and C, error handling in C++ - and hence in the entire B2000++ source code - should be implemented making use of exceptions.
The C++ exception mechanism permits to decouple the code where an error is detected from the code that handles the error. To this end, the code that detected an error creates an object and "throws" it, while the code that handles that particular error "catches" the object. At the place where the object is caught, it can be used like any other object. Therefore the error message, the type of error, the reason, etc. are usually put in such objects.
The b2000::Exception class is fundamental to B2000++'s error handling facility. It contains:
To throw a generic Exception:
The THROW macro (also defined in b2exception.H) sets file name and line number.
Example:
The Exception class contains support for obtaining the backtrace (list of all functions going back to the place where the exception was raised) on platforms where a recent version of the GNU C/C++ compiler and associated binutils package is used.
In addition, a set of pre-defined specializations of b2000::Exception is defined, notably:
It is recommended to make use of these specializations where appropriate.
#define THROW Exception::Throw(__FILE__, __LINE__) |
Create a Throw/Warning structure with the current file name and line number. To be used as follows: