concepts::ExceptionBase Class Reference
Base class for exceptions. More...
#include <exceptions.hh>
Public Member Functions | |
ExceptionBase () throw () | |
Default constructor. More... | |
ExceptionBase (const std::string &file, const unsigned int line, const std::string &function, const std::string &excName) throw () | |
Constructor. More... | |
ExceptionBase (const std::string &message) throw () | |
void | setFields (const std::string &file, const unsigned int line, const std::string &function, const std::string &excName) throw () |
Sets the fields of this exception. More... | |
virtual | ~ExceptionBase () throw () |
Protected Member Functions | |
virtual std::ostream & | info (std::ostream &os) const throw () |
Returns information in an output stream. More... | |
Protected Attributes | |
std::string | excName_ |
The name of the exception with calling sequence. More... | |
std::string | file_ |
Filename where the exception was thrown from. More... | |
std::string | function_ |
Name of the function that threw the exception. More... | |
unsigned int | line_ |
Line where the exception was thrown from. More... | |
Detailed Description
Base class for exceptions.
This class features informations about the exceptions thrown, ie. filename and line, name of the function and of the exception. The ouput operator (<<) can display this information.
The typical usage of this class is to throw an exception if an error has occured. This can be done by
throw conceptsException(ExceptionBase());
These exceptions are always present (in a production code as well as in development code). If you want to have assertions using exceptions (which are only in the development code), have a look at Assertion and conceptsAssert.
There are two different error cases:
-
The error is a real programming error and should not happen during normal and correct operation. Such an error is caught with an assertion. Such an assertion can be thrown (using an exception) by
conceptsAssert(1 == 0, Assertion());
These assertions are not working with the optimised version of the library -
An error which can also happen during normal operation of the library which should also be detected in optimised mode. Such an error is caught with a normal throw. To use to provided classes comfortably, use the macro conceptsException like this:
throw conceptsException(ExceptionBase());
- See also
- conceptsException
- conceptsAssert
- Assertion
- Examples
- arpackppTutorial.cc, BGT_0.cc, cig_load_input_data.cc, elasticity2D_tutorial.cc, exactDtN.cc, hpFEM2d-simple.cc, hpFEM2d.cc, hpFEM3d-EV.cc, inhomDirichletBCs.cc, inhomDirichletBCsLagrange.cc, inhomNeumannBCs.cc, inputoutput.cc, linearDG1d.cc, linearFEM1d-simple.cc, linearFEM1d.cc, matfileTutorial.cc, and RobinBCs.cc.
Definition at line 84 of file exceptions.hh.
Constructor & Destructor Documentation
◆ ExceptionBase() [1/3]
concepts::ExceptionBase::ExceptionBase | ( | ) | ||
throw | ( | |||
) |
Default constructor.
◆ ExceptionBase() [2/3]
|
inline |
Definition at line 91 of file exceptions.hh.
◆ ExceptionBase() [3/3]
concepts::ExceptionBase::ExceptionBase | ( | const std::string & | file, |
const unsigned int | line, | ||
const std::string & | function, | ||
const std::string & | excName | ||
) | |||
throw | ( | ||
) |
Constructor.
- Parameters
-
file Filename where the exception was thrown from line Line where the exception was thrown from function Name of the function that threw the exception excName The name of the exception
◆ ~ExceptionBase()
|
virtual |
Member Function Documentation
◆ info()
|
protectedvirtual |
Returns information in an output stream.
Reimplemented from concepts::OutputOperator.
Reimplemented in concepts::MissingParameter, concepts::NewtonException, concepts::MumpsException, concepts::PointerToEmptyBilinearForm, concepts::MatfileIOError, concepts::StrategyChange, concepts::GmshInputException, concepts::Ez4uException, concepts::FFEF_Error, concepts::NegativeJacobian, concepts::FormulaSyntaxError, concepts::PointerToEmptyFormula, concepts::PointerToEmptyElementFormula, concepts::ElementNotInDomainOfFormula, concepts::ImplicitEquilibratedA0Error, concepts::FluxesError, test::TestSuiteError, concepts::NoMPIInit_Error, concepts::NoConvergence, concepts::FortranException, concepts::FileOpenError, concepts::Assertion, concepts::MissingFeature, and concepts::WrongInputException.
◆ setFields()
void concepts::ExceptionBase::setFields | ( | const std::string & | file, |
const unsigned int | line, | ||
const std::string & | function, | ||
const std::string & | excName | ||
) | |||
throw | ( | ||
) |
Sets the fields of this exception.
- Parameters
-
file Filename where the exception was thrown from line Line where the exception was thrown from function Name of the function that threw the exception excName The name of the exception
Member Data Documentation
◆ excName_
|
protected |
The name of the exception with calling sequence.
Definition at line 132 of file exceptions.hh.
◆ file_
|
protected |
Filename where the exception was thrown from.
Definition at line 123 of file exceptions.hh.
◆ function_
|
protected |
Name of the function that threw the exception.
Definition at line 129 of file exceptions.hh.
◆ line_
|
protected |
Line where the exception was thrown from.
Definition at line 126 of file exceptions.hh.
The documentation for this class was generated from the following file:
- basics/exceptions.hh