OpenWalnut  1.5.0dev
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | Friends | List of all members
WException Class Reference

Basic exception handler. More...

#include <WException.h>

+ Inheritance diagram for WException:
+ Collaboration diagram for WException:

Public Member Functions

 WException (const std::string &msg=std::string())
 Default constructor. More...
 
 WException (const std::exception &e)
 Copy a std::exception and encapsulate it. More...
 
virtual ~WException () throw ()
 Destructor. More...
 
virtual const char * what () const throw ()
 Returns the message string set on throw. More...
 
std::string getTrace () const
 Prints the trace of the call chain which caused this exception. More...
 
std::string getBacktrace () const
 Returns a call stacktrace. More...
 

Static Public Member Functions

static void disableBacktrace ()
 Function disables backtraces. More...
 

Protected Attributes

std::string m_msg
 Message given during throw. More...
 
std::list< std::string > m_trace
 Stack trace for identifying the source where this exception came from. More...
 

Static Protected Attributes

static bool noBacktrace = false
 True if the backtrace should NOT be printed. More...
 

Private Attributes

WTerminalColor m_labelColor
 Color used for the "trace:" label. More...
 
WTerminalColor m_functionColor
 Color used for function name. More...
 
WTerminalColor m_symbolColor
 Color used for symbols. More...
 
WTerminalColor m_headlineColor
 Color used for exception headline. More...
 

Friends

class WExceptionTest
 Only UnitTests are allowed to be a friend of this class. More...
 

Detailed Description

Basic exception handler.

Definition at line 38 of file WException.h.

Constructor & Destructor Documentation

◆ WException() [1/2]

WException::WException ( const std::string &  msg = std::string())
explicit

Default constructor.

Parameters
msgException description.

Definition at line 50 of file WException.cpp.

References getBacktrace(), m_headlineColor, m_msg, and noBacktrace.

+ Here is the call graph for this function:

◆ WException() [2/2]

WException::WException ( const std::exception &  e)
explicit

Copy a std::exception and encapsulate it.

Parameters
ethe exception.

Definition at line 68 of file WException.cpp.

References getBacktrace(), m_headlineColor, m_msg, and noBacktrace.

+ Here is the call graph for this function:

◆ ~WException()

WException::~WException ( )
throw (
)
virtual

Destructor.

Definition at line 85 of file WException.cpp.

Member Function Documentation

◆ disableBacktrace()

void WException::disableBacktrace ( )
static

◆ getBacktrace()

std::string WException::getBacktrace ( ) const

Returns a call stacktrace.

Returns
The backtrace at the moment of "throw".

Definition at line 107 of file WException.cpp.

References m_functionColor, m_labelColor, m_symbolColor, and what().

Referenced by WExceptionTest::testBacktrace(), and WException().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTrace()

std::string WException::getTrace ( ) const

Prints the trace of the call chain which caused this exception.

Returns
Calltrace as string
Note
Isn't this useless? Should be removed.

Definition at line 96 of file WException.cpp.

References m_trace, and what().

Referenced by WExceptionTest::testGetMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ what()

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

Friends And Related Function Documentation

◆ WExceptionTest

friend class WExceptionTest
friend

Only UnitTests are allowed to be a friend of this class.

Definition at line 43 of file WException.h.

Member Data Documentation

◆ m_functionColor

WTerminalColor WException::m_functionColor
private

Color used for function name.

Definition at line 114 of file WException.h.

Referenced by getBacktrace().

◆ m_headlineColor

WTerminalColor WException::m_headlineColor
private

Color used for exception headline.

Definition at line 124 of file WException.h.

Referenced by WException().

◆ m_labelColor

WTerminalColor WException::m_labelColor
private

Color used for the "trace:" label.

Definition at line 109 of file WException.h.

Referenced by getBacktrace().

◆ m_msg

std::string WException::m_msg
protected

Message given during throw.

Definition at line 93 of file WException.h.

Referenced by WException(), what(), and WSegmentationFault::WSegmentationFault().

◆ m_symbolColor

WTerminalColor WException::m_symbolColor
private

Color used for symbols.

Definition at line 119 of file WException.h.

Referenced by getBacktrace().

◆ m_trace

std::list< std::string > WException::m_trace
protected

Stack trace for identifying the source where this exception came from.

Note
Isn't this useless? Should be removed.

Definition at line 99 of file WException.h.

Referenced by getTrace(), and WExceptionTest::testGetMessage().

◆ noBacktrace

bool WException::noBacktrace = false
staticprotected

True if the backtrace should NOT be printed.

initialize static member.

Definition at line 104 of file WException.h.

Referenced by disableBacktrace(), and WException().


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