From 74d256f0fe1dd0ac95d26dc89e6636ad52c5c66e Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 30 Jan 2017 01:47:00 -0500 Subject: [PATCH] bees: handle trace functions that throw exceptions A BEESTRACE closure could throw an exception. Trap those so we don't end up in terminate(). Signed-off-by: Zygo Blaxell (cherry picked from commit 59660cfc00b9ca233eeb1a7cdf6df34a45a2deba) --- src/bees.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bees.cc b/src/bees.cc index 1efaf78..55fb240 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -51,7 +51,13 @@ thread_local BeesTracer *BeesTracer::tl_next_tracer = nullptr; BeesTracer::~BeesTracer() { if (uncaught_exception()) { - m_func(); + try { + m_func(); + } catch (exception &e) { + BEESLOG("Nested exception: " << e.what()); + } catch (...) { + BEESLOG("Nested exception ..."); + } if (!m_next_tracer) { BEESLOG("--- END TRACE --- exception ---"); }