mirror of
				https://github.com/Zygo/bees.git
				synced 2025-10-31 10:10:34 +01:00 
			
		
		
		
	trace: current_exception() is not a replacement for uncaught_exception()
In15ab981d9e"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:
		| @@ -8,9 +8,25 @@ thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr; | ||||
| thread_local bool BeesTracer::tl_first = true; | ||||
| 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() | ||||
| { | ||||
| 	if (!tl_silent && current_exception()) { | ||||
| 	if (!tl_silent && exception_check()) { | ||||
| 		if (tl_first) { | ||||
| 			BEESLOGNOTICE("--- BEGIN TRACE --- exception ---"); | ||||
| 			tl_first = false; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user