From: Gunnar Beutner Date: Fri, 8 Mar 2013 13:43:07 +0000 (+0100) Subject: Catch exceptions in EventQueue::QueueThreadProc. X-Git-Tag: v0.0.2~321 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13436cb53610dc023fadf4370f4bcf789061be59;p=icinga2 Catch exceptions in EventQueue::QueueThreadProc. --- diff --git a/lib/base/eventqueue.cpp b/lib/base/eventqueue.cpp index 921310e03..ba58ad001 100644 --- a/lib/base/eventqueue.cpp +++ b/lib/base/eventqueue.cpp @@ -103,7 +103,17 @@ void EventQueue::QueueThreadProc(void) # endif /* RUSAGE_THREAD */ #endif /* _DEBUG */ - ev(); + try { + ev(); + } catch (const std::exception& ex) { + stringstream msgbuf; + msgbuf << "Exception thrown in event handler: " << std::endl + << diagnostic_information(ex); + + Logger::Write(LogCritical, "base", msgbuf.str()); + } catch (...) { + Logger::Write(LogCritical, "base", "Exception of unknown type thrown in event handler."); + } #ifdef _DEBUG double et = Utility::GetTime();