Base class for exceptions. More...

#include <exceptions.hh>

Inheritance diagram for concepts::ExceptionBase:
concepts::OutputOperator bem::NoOfIntegrationPointsToHigh cluster::CacheSizeExceeded concepts::DimensionMismatch concepts::ElementNotInDomainOfFormula concepts::Ez4uException concepts::FFEF_Error concepts::FluxesError concepts::GmshInputException concepts::ImplicitEquilibratedA0Error concepts::IndexNotExisting concepts::MatfileIOError concepts::MatrixNotBuilt concepts::MissingFeature concepts::ModelNotSolved concepts::NoMPIInit_Error concepts::NotValidDof concepts::PointerToEmptyBilinearForm concepts::PointerToEmptyElementFormula concepts::PointerToEmptyFormula concepts::SpaceNotBuilt concepts::StrategyChange concepts::WrongInputException concepts::WrongRelations hp2D::NotConnectedIndex vectorial::ElementNotBuilt

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
Test:
test::ExceptionTest
Author
Philipp Frauenfelder, 2000
Robert Gruhlke, 2016
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]

concepts::ExceptionBase::ExceptionBase ( const std::string &  message)
throw (
)
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
fileFilename where the exception was thrown from
lineLine where the exception was thrown from
functionName of the function that threw the exception
excNameThe name of the exception

◆ ~ExceptionBase()

virtual concepts::ExceptionBase::~ExceptionBase ( )
throw (
)
virtual

Member Function Documentation

◆ info()

◆ 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
fileFilename where the exception was thrown from
lineLine where the exception was thrown from
functionName of the function that threw the exception
excNameThe name of the exception

Member Data Documentation

◆ excName_

std::string concepts::ExceptionBase::excName_
protected

The name of the exception with calling sequence.

Definition at line 132 of file exceptions.hh.

◆ file_

std::string concepts::ExceptionBase::file_
protected

Filename where the exception was thrown from.

Definition at line 123 of file exceptions.hh.

◆ function_

std::string concepts::ExceptionBase::function_
protected

Name of the function that threw the exception.

Definition at line 129 of file exceptions.hh.

◆ line_

unsigned int concepts::ExceptionBase::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:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich