Exception class for assertions. More...

#include <exceptions.hh>

Inheritance diagram for concepts::Assertion:
concepts::MissingFeature concepts::ExceptionBase concepts::OutputOperator

Public Member Functions

 Assertion () throw ()
 Default constructor. More...
 
 Assertion (const std::string &file, const unsigned int line, const std::string &function, const std::string &excName, const std::string &cond) throw ()
 Constructor. More...
 
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...
 
void setFieldsAssert (const std::string &file, const unsigned int line, const std::string &function, const std::string &excName, const std::string &cond=std::string("")) throw ()
 Sets the fields of this exception. More...
 
virtual ~Assertion () 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 feature_
 Missing feature. 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

Exception class for assertions.

Besides the information already present in ExceptionBase, this class features more information about the assertion which failed. The ouput operator (<<) can display this information.

The typical usage of this class is to throw an exception if an assertion has failed. This can be done by

conceptsAssert(1 == 0, Assertion());

These exceptions are not always present, since the macro conceptsAssert is switched off in production code. If you want to have exceptions which are always present, have a look at ExceptionBase and conceptsException.

See also
conceptsAssert
conceptsException
ExceptionBase
Test:
test::ExceptionTest
Author
Philipp Frauenfelder, 2000
Examples
hpFEM2d.cc, linearFEM1d-simple.cc, and linearFEM1d.cc.

Definition at line 258 of file exceptions.hh.

Constructor & Destructor Documentation

◆ Assertion() [1/2]

concepts::Assertion::Assertion ( )
throw (
)

Default constructor.

◆ Assertion() [2/2]

concepts::Assertion::Assertion ( const std::string &  file,
const unsigned int  line,
const std::string &  function,
const std::string &  excName,
const std::string &  cond 
)
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
condCondition which was violated

◆ ~Assertion()

virtual concepts::Assertion::~Assertion ( )
throw (
)
virtual

Member Function Documentation

◆ info()

virtual std::ostream& concepts::Assertion::info ( std::ostream &  os) const
throw (
)
protectedvirtual

Returns information in an output stream.

Reimplemented from concepts::MissingFeature.

◆ setFields()

void concepts::ExceptionBase::setFields ( const std::string &  file,
const unsigned int  line,
const std::string &  function,
const std::string &  excName 
)
throw (
)
inherited

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

◆ setFieldsAssert()

void concepts::Assertion::setFieldsAssert ( const std::string &  file,
const unsigned int  line,
const std::string &  function,
const std::string &  excName,
const std::string &  cond = std::string("") 
)
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
condCondition which was violated

Member Data Documentation

◆ excName_

std::string concepts::ExceptionBase::excName_
protectedinherited

The name of the exception with calling sequence.

Definition at line 132 of file exceptions.hh.

◆ feature_

std::string concepts::MissingFeature::feature_
protectedinherited

Missing feature.

Definition at line 231 of file exceptions.hh.

◆ file_

std::string concepts::ExceptionBase::file_
protectedinherited

Filename where the exception was thrown from.

Definition at line 123 of file exceptions.hh.

◆ function_

std::string concepts::ExceptionBase::function_
protectedinherited

Name of the function that threw the exception.

Definition at line 129 of file exceptions.hh.

◆ line_

unsigned int concepts::ExceptionBase::line_
protectedinherited

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