chsvlib
chsv helper source code
chsvexception\chsv_list_of_exceptions.cpp

An example of using the chsv_monitor_exceptions and chsv_list_of_exceptions macros.

#include <iostream>
#include "chsvexception.h"
void f3()
{
}
void f2()
{
f3();
}
struct Obj
{
void fo()
{
f2();
}
};
void f1()
{
Obj x;
x.fo();
}
int wmain(int argc, wchar_t **argv)
{
try
{
f1();
{
std::wcout << L"Exception caught: " << ex.What() << std::endl;
std::wcout << L"Stack trace (from top to bottom):\n";
size_t i = 0;
for (auto& entry:chsv_list_of_exceptions)
std::wcout << ++i << L") " << entry.Record() << std::endl;
}
return 0;
}
/*
Output:
=======
Exception caught: Invalid parameter
Stack trace (from top to bottom):
1) chsv_list_of_exceptions.cpp:35: wmain
2) chsv_list_of_exceptions.cpp:26: f1
3) chsv_list_of_exceptions.cpp:19: Obj::fo
4) chsv_list_of_exceptions.cpp:11: f2
5) chsv_list_of_exceptions.cpp:6: f3
*/
The file contains definitions of various exceptions thrown by the mechanisms of the chsvcode library ...
Defines a class of objects specifying various exceptions with extended support for description format...
Definition: chsvexception.h:392
virtual const wchar_t * What() const noexcept
Returns a description, corresponding to the exception, represented as a wide string.
Definition: chsvexception.h:573
#define chsv_monitor_exceptions
Turns on exception tracing during stack unwinding within a function.
Definition: chsvexception.h:5216
void ChsvExceptionByPosixCode(errno_t nCode, const char *restrict pszDescription, DescriptionFormatParams ... format_params)
Creates an instance of the ChsvCodeExceptionTempl class and throws it as an exception....
Definition: chsvexception.h:4259
#define chsv_list_of_exceptions
Returns a list of registered exceptions thrown within a current thread with the front elements being ...
Definition: chsvexception.h:5235