ErrLib
Public Member Functions | List of all members
ErrLib::Exception Class Reference

#include <ErrLib_CPP.h>

Inheritance diagram for ErrLib::Exception:
ErrLib::ComException ErrLib::WinapiException

Public Member Functions

 Exception ()
 
 Exception (const std::wstring &message)
 
 Exception (const std::wstring &message, DWORD code, void *data)
 
std::wstring GetMsg ()
 
DWORD GetCode ()
 
void * GetData ()
 
void GetMessageText (WCHAR *pOutput, int cch)
 
void GetContext (CONTEXT *pOutput)
 
void PrintStackTrace (WCHAR *pOutput, int cch)
 
std::wstring PrintStackTrace ()
 
void Log (bool visible)
 

Detailed Description

Provides a base class for C++ exceptions that supports capturing a stack trace in the moment when exception is thrown and logging the exception information.

Constructor & Destructor Documentation

◆ Exception() [1/3]

ErrLib::Exception::Exception ( )
inline

Creates a new exception using the default empty error message

◆ Exception() [2/3]

ErrLib::Exception::Exception ( const std::wstring &  message)
inline

Creates a new exception using the specified error message

◆ Exception() [3/3]

ErrLib::Exception::Exception ( const std::wstring &  message,
DWORD  code,
void *  data 
)
inline

Creates a new exception using the specified error message, error code and additional data

Member Function Documentation

◆ GetCode()

DWORD ErrLib::Exception::GetCode ( )
inline

Gets the error code associated with this exception

Note
When error code was not specified when creating exception, the default value DWORD ERRLIB_CPP_EXCEPTION (0xC0400002) is used.

◆ GetContext()

void ErrLib::Exception::GetContext ( CONTEXT *  pOutput)
inline

Gets the processor context in the moment this exception was thrown

Parameters
pOutputThe pointer to the caller-allocated buffer to store the CONTEXT structure. Must be at least sizeof(CONTEXT) bytes.

◆ GetData()

void * ErrLib::Exception::GetData ( )
inline

Gets the additional user-defined data associated with this exception

◆ GetMessageText()

void ErrLib::Exception::GetMessageText ( WCHAR *  pOutput,
int  cch 
)
inline

Gets the error message associated with this exception as a C wide-character string

Parameters
pOutputThe pointer to the caller-allocated wide character array that will be filled with error message text on output.
cchThe maximum amount of characters that can be put into the array pointed by pOutput parameter.

◆ GetMsg()

std::wstring ErrLib::Exception::GetMsg ( )
inline

Gets the error message associated with this exception as a C++ wstring

◆ Log()

void ErrLib::Exception::Log ( bool  visible)
inline

Outputs the exception information into configured log targets

Parameters
visiblePass true if you want to use ERRLIB_OUTPUT_STDERR/ERRLIB_OUTPUT_MBOX logging targets (if they are enabled by configuration flags), false otherwise This method outputs information into one or more logging targets, configured using ErrLib_SetParameter function. It only outputs information into the stderr stream and message box if the visible parameter is true (and if respective flags are enabled). By default, the enabled logging targets are log file and stderr stream.
Note
When outputting information in message box, stack trace is not included.

◆ PrintStackTrace() [1/2]

std::wstring ErrLib::Exception::PrintStackTrace ( )
inline

Gets the stack trace in the moment this exception was thrown as a C++ wstring

◆ PrintStackTrace() [2/2]

void ErrLib::Exception::PrintStackTrace ( WCHAR *  pOutput,
int  cch 
)
inline

Gets the stack trace in the moment this exception was thrown as a C wide-character string

Parameters
pOutputThe pointer to the caller-allocated wide character array that will be filled with stack trace text on output.
cchThe maximum amount of characters that can be put into the array pointed by pOutput parameter.

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