mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
trace: current_exception() is not a replacement for uncaught_exception()
In 15ab981d9e "bees: replace uncaught_exception(), deprecated in C++17", uncaught_exception() was replaced with current_exception(); however, current_exception() is only valid after an exception has been captured by a catch block. BeesTracer wants to know about exceptions _before_ they are caught, so current_exception() is not useful here. Instead, conditionally compile using uncaught_exception() or uncaught_exceptions(), selected by C++ standard version, and make bees stack traces work again. Fixes: 15ab981d9e "bees: replace uncaught_exception(), deprecated in C++17" Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
03532effed
commit
08899052ad
@ -8,9 +8,25 @@ thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr;
|
|||||||
thread_local bool BeesTracer::tl_first = true;
|
thread_local bool BeesTracer::tl_first = true;
|
||||||
thread_local bool BeesTracer::tl_silent = false;
|
thread_local bool BeesTracer::tl_silent = false;
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
exception_check()
|
||||||
|
{
|
||||||
|
return uncaught_exceptions();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static
|
||||||
|
bool
|
||||||
|
exception_check()
|
||||||
|
{
|
||||||
|
return uncaught_exception();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BeesTracer::~BeesTracer()
|
BeesTracer::~BeesTracer()
|
||||||
{
|
{
|
||||||
if (!tl_silent && current_exception()) {
|
if (!tl_silent && exception_check()) {
|
||||||
if (tl_first) {
|
if (tl_first) {
|
||||||
BEESLOGNOTICE("--- BEGIN TRACE --- exception ---");
|
BEESLOGNOTICE("--- BEGIN TRACE --- exception ---");
|
||||||
tl_first = false;
|
tl_first = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user