dxd - dynax driver framework 3.0.1d223
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx_exception.h File Reference
#include "dx_ansi_colors.h"
#include <stdexcept>
#include <exception>
#include <iomanip>
#include <chrono>
#include <mutex>
#include <sstream>
Include dependency graph for dx_exception.h:
This graph shows which files directly or indirectly include this file:

Classes

class  dx::exception
 a throw's whole diagnostic: the OS result, where it was raised (frame, file, line), the thread and the moment, a formatted comment and the exception it grew out of. Each frame on the way out wraps the one below into a new exception of its own - dx_catchall and friends do nothing else - so previous is the chain down to the origin, deep copied and owned by the wrapper; dx::trace::unfold prints it. The constructor overloads below are one signature per combination of the optional leading arguments (previous, function, error, what) ahead of the mandatory frame/file/line, with and without the printf-style comment. More...

Namespaces

namespace  dx
 dynax driver framework interface namespace
namespace  dx::color
 the SGR sequences, by their effect; dx::themed picks between two of them
namespace  dx::fourchar
 the four character codes of the OS audio APIs: to::string prints the printable bytes and the numeric value of the others, from::string packs four bytes back into the word
namespace  dx::fourchar::to
namespace  dx::thread
 thread
namespace  dx::trace

Macros

#define __dx_catchall(inject, ...)
#define dx_catchall(inject, ...)
#define dx_catchall_handler(object, inject, ...)
#define dx_catchall_handler_or_rethrow(object, test, inject, ...)
#define dx_catchall_rethrow(inject, ...)
#define dx_pass(test, ...)
#define dx_pass_discard   dx_assert
#define dx_pass_strict(test, ...)

Functions

void dx::halt ()
 the breakpoint a dx_pass/dx_assert failure runs into - a debugger's stop is one uncommented line away
std::string dx::thread::name ()
std::ostream & dx::operator<< (std::ostream &os, const exception &exception) noexcept
std::string dx::trace::pretty (std::string function) noexcept
 a __PRETTY_FUNCTION__ without its template arguments - the frames of one template read alike then
void dx::report_uncaught ()
 prints an uncaught exception's actual diagnostic to stderr before the runtime terminates the process. Call once at startup - std::terminate() (an uncaught throw reaching main(), or escaping any std::thread's entry function) otherwise calls abort() with no diagnostic output at all.
std::string dx::fourchar::to::string (uint32_t fourchar)
void dx::trace::unfold (std::ostream &os, const exception &exception, unsigned int indent=0) noexcept
 the chain from the given exception down to its origin, each frame indented by two

Variables

std::recursive_mutex dx::io_mutex
 the one lock every diagnostic sink takes, so a chain unfolded from one thread stays unbroken

Macro Definition Documentation

◆ __dx_catchall

#define __dx_catchall ( inject,
... )
Value:
DX_PRAGMA_IGNORE_RETURN_VALUE_BEGIN\
catch(const dx::exception& __dx_exception){\
try{\
dx::exception exception{\
&__dx_exception,\
__dx_exception.error,\
__FILE__, static_cast<unsigned int>(__LINE__),\
##__VA_ARGS__};\
inject\
}catch(...){}\
}catch(const std::exception& __std_exception){\
try{\
dx::exception exception{\
std::string{__std_exception.what()},\
__FILE__, static_cast<unsigned int>(__LINE__),\
##__VA_ARGS__};\
inject\
}catch(...){}\
}catch(...){\
try{\
dx::exception exception{\
__FILE__, static_cast<unsigned int>(__LINE__),\
##__VA_ARGS__};\
inject\
}catch(...){}\
}\
DX_PRAGMA_IGNORE_RETURN_VALUE_END
a throw's whole diagnostic: the OS result, where it was raised (frame, file, line),...
Definition dx_exception.h:186
os_result error
Definition dx_exception.h:189
#define __PRETTY_FUNCTION__
mock compiler idiosyncrasies
Definition windows/dx_platform.h:50

◆ dx_catchall

#define dx_catchall ( inject,
... )
Value:
__dx_catchall(inject std::cerr<< \
dx::exception(&exception, exception.error, __PRETTY_FUNCTION__, __FILE__, __LINE__)<< \
std::endl;, ##__VA_ARGS__)
#define __dx_catchall(inject,...)
Definition dx_exception.h:77

◆ dx_catchall_handler

#define dx_catchall_handler ( object,
inject,
... )
Value:
__dx_catchall(inject \
(object)->exception({&exception, exception.error, __PRETTY_FUNCTION__, __FILE__, __LINE__});, \
##__VA_ARGS__)

◆ dx_catchall_handler_or_rethrow

#define dx_catchall_handler_or_rethrow ( object,
test,
inject,
... )
Value:
(object)->exception(dx::exception{&exception, exception.error, __PRETTY_FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__});\
inject\
}else,\
##__VA_ARGS__)\
#define dx_catchall_rethrow(inject,...)
Definition dx_exception.h:122

◆ dx_catchall_rethrow

#define dx_catchall_rethrow ( inject,
... )

◆ dx_pass

#define dx_pass ( test,
... )
Value:
{\
dx::os_result __dx_test_status=(test);\
if(dx::os_error(__dx_test_status)){\
dx::halt();\
throw dx::exception{\
DX_STRINGIFY(test),\
__dx_test_status,\
__FILE__, static_cast<unsigned int>(__LINE__),\
##__VA_ARGS__};}}
bool os_error(os_result result) noexcept
Definition macOS/dx_platform.h:205
::IOReturn os_result
defining platform abstract type os_result for IOKit driver
Definition driverkit/dxd_platform.h:49

◆ dx_pass_discard

#define dx_pass_discard   dx_assert

◆ dx_pass_strict

#define dx_pass_strict ( test,
... )
Value:
{\
dx::os_result __dx_test_status=(test);\
if(__dx_test_status){\
dx::halt();\
throw dx::exception{\
DX_STRINGIFY(test),\
__dx_test_status,\
__FILE__, static_cast<unsigned int>(__LINE__),\
##__VA_ARGS__};}}

(c) copyright 2009 dynamic acoustics e.U. generated on

a closed source license may be obtained by requesting a written permission from dynamic acoustics e.U.
however - governmental use generally and military use especially is strictly prohibited though.