Flow123d  jenkins-Flow123d-windows-release-multijob-285
Public Member Functions | Private Attributes | List of all members
ExceptionBase Class Referenceabstract

Base of exceptions used in Flow123d. More...

#include <exceptions.hh>

Inheritance diagram for ExceptionBase:
Inheritance graph
[legend]
Collaboration diagram for ExceptionBase:
Collaboration graph
[legend]

Public Member Functions

 ExceptionBase ()
 Default constructor, just calls fill_stacktrace(). More...
 
 ExceptionBase (const ExceptionBase &other)
 Copy constructor, performs deep copy of stacktrace. More...
 
void fill_stacktrace ()
 Call GNU backtrace if available, save call stack information into stacktrace member. More...
 
void print_stacktrace (std::ostream &out) const
 Prints formated stacktrace into given stream out. More...
 
virtual void print_info (std::ostringstream &out) const =0
 
virtual const char * what () const throw ()
 
virtual ~ExceptionBase () throw ()
 Destructor, possibly free stacktrace. More...
 

Private Attributes

char ** stacktrace
 Array of backtrace frames returned by glibc backtrace_symbols. More...
 
int n_stacktrace_frames
 Size of stacktrace table - number of frames. More...
 

Detailed Description

Base of exceptions used in Flow123d.

We use boost::exception as parent in order to allow passing some data through the exception object from the throw point to the catch point. See DECLARE_EXCEPTION macro for usage.

When deriving particular exceptions always use virtual inheritance:

struct my_exception : virtual ExceptionBase {};

Definition at line 55 of file exceptions.hh.

Constructor & Destructor Documentation

ExceptionBase::ExceptionBase ( )

Default constructor, just calls fill_stacktrace().

Definition at line 22 of file exceptions.cc.

ExceptionBase::ExceptionBase ( const ExceptionBase other)

Copy constructor, performs deep copy of stacktrace.

Definition at line 30 of file exceptions.cc.

ExceptionBase::~ExceptionBase ( )
throw (
)
virtual

Destructor, possibly free stacktrace.

Definition at line 48 of file exceptions.cc.

Member Function Documentation

void ExceptionBase::fill_stacktrace ( )

Call GNU backtrace if available, save call stack information into stacktrace member.

Definition at line 57 of file exceptions.cc.

Here is the caller graph for this function:

virtual void ExceptionBase::print_info ( std::ostringstream &  out) const
pure virtual

Purely virtual method, that should be implemented by descendants. Prints specific error message into stream out. In particular you can use macros DECLARE_EXCEPTION or DECLARE_INPUT_EXCEPTION for easy declarations.

Here is the caller graph for this function:

void ExceptionBase::print_stacktrace ( std::ostream &  out) const

Prints formated stacktrace into given stream out.

Definition at line 75 of file exceptions.cc.

Here is the caller graph for this function:

const char * ExceptionBase::what ( ) const
throw (
)
virtual

Overloaded method for output the exception message if it is not catched. Implements composition of complex message including diagnostic informations and stack trace. Should not be overloded in descendant classes. Use print_info instead.

Reimplemented in Input::Exception.

Definition at line 116 of file exceptions.cc.

Member Data Documentation

int ExceptionBase::n_stacktrace_frames
private

Size of stacktrace table - number of frames.

Definition at line 86 of file exceptions.hh.

char** ExceptionBase::stacktrace
private

Array of backtrace frames returned by glibc backtrace_symbols.

Definition at line 83 of file exceptions.hh.


The documentation for this class was generated from the following files: