MIRA
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Exception Class Reference

Base class for exceptions. More...

#include <error/Exception.h>

Inheritance diagram for Exception:
Inheritance graph
[legend]

Classes

struct  Info
 The info packet that is added in MIRA_THROW and MIRA_RETHROW. More...
 

Public Member Functions

 Exception (std::string message, const char *file=NULL, int line=0) MIRA_NOEXCEPT_OR_NOTHROW
 The constructor. More...
 
virtual ~Exception () MIRA_NOEXCEPT_OR_NOTHROW
 Destructor. More...
 
void addInfo (std::string message, const char *file=NULL, int line=0)
 Adds additional information to the exception. More...
 
virtual const char * what () const MIRA_NOEXCEPT_OR_NOTHROW
 Returns the text of exception containing the information given in MIRA_THROW and MIRA_RETHROW as well as the file name and line number where it was thrown. More...
 
std::string message () const MIRA_NOEXCEPT_OR_NOTHROW
 Similar to what(). More...
 
const CallStackcallStack () const
 Returns the state of the callstack at the moment when the exception was thrown. More...
 
ThreadID getThreadID () const
 Returns the id of the thread where the exception was thrown. More...
 
template<typename DerivedException >
DerivedException & addStackInfo ()
 FOR INTERNAL USE ONLY. More...
 
template<typename DerivedException >
DerivedException & addExternalStackInfo (CallStack stack, ThreadID thread)
 Stores the provided callstack and thread id within the exception. More...
 
const InfogetInfo () const
 Returns the first info packet that describes the location where the exception has occured. More...
 

Protected Member Functions

 Exception () MIRA_NOEXCEPT_OR_NOTHROW
 

Protected Attributes

std::list< InfomInfos
 
CallStack mStack
 
ThreadID mThreadID
 
std::string mMessage
 as cache for what() More...
 

Detailed Description

Base class for exceptions.

The what()-text contains file name and line number where the exception was thrown as well as additional information that was specified in MIRA_THROW and MIRA_RETHROW.

This exception class also keeps track of the call stack, which can be used to improve tracing of errors and exceptions.

For detailed information see Error and Exception Handling.

See also
MIRA_THROW, MIRA_RETHROW

Constructor & Destructor Documentation

◆ Exception() [1/2]

Exception ( )
inlineprotected

◆ Exception() [2/2]

Exception ( std::string  message,
const char *  file = NULL,
int  line = 0 
)
inline

The constructor.

Note
Ususally this constructor is not called directly, instead MIRA_THROW should be used to create and throw an exception.
See also
MIRA_THROW

◆ ~Exception()

virtual ~Exception ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ addInfo()

void addInfo ( std::string  message,
const char *  file = NULL,
int  line = 0 
)
inline

Adds additional information to the exception.

Note
Ususally this method is not called directly, instead MIRA_RETHROW should be used to add additional information and to rethrow the exception.
See also
MIRA_THROW, MIRA_RETHROW

◆ what()

virtual const char* what ( ) const
virtual

Returns the text of exception containing the information given in MIRA_THROW and MIRA_RETHROW as well as the file name and line number where it was thrown.

See also
MIRA_THROW, MIRA_RETHROW

◆ message()

std::string message ( ) const

Similar to what().

Returns the text of exception containing the information given in MIRA_THROW and MIRA_RETHROW without the file name and line number in a single line string.

See also
MIRA_THROW, MIRA_RETHROW

◆ callStack()

const CallStack& callStack ( ) const
inline

Returns the state of the callstack at the moment when the exception was thrown.

◆ getThreadID()

ThreadID getThreadID ( ) const
inline

Returns the id of the thread where the exception was thrown.

◆ addStackInfo()

DerivedException& addStackInfo ( )
inline

FOR INTERNAL USE ONLY.

Stores the current callstack and thread id within the exception. This method is called by the MIRA_THROW macro and is for internal use. You never need to call this method manually.

◆ addExternalStackInfo()

DerivedException& addExternalStackInfo ( CallStack  stack,
ThreadID  thread 
)
inline

Stores the provided callstack and thread id within the exception.

This can be used to create an exception with a callstack from an external source (e.g. for an exception originally thrown in an RPC).

◆ getInfo()

const Info& getInfo ( ) const
inline

Returns the first info packet that describes the location where the exception has occured.

Member Data Documentation

◆ mInfos

std::list<Info> mInfos
protected

◆ mStack

CallStack mStack
protected

◆ mThreadID

ThreadID mThreadID
protected

◆ mMessage

std::string mMessage
mutableprotected

as cache for what()


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