diff --git a/common/source/EventThread.cpp b/common/source/EventThread.cpp index e46662118..d9c8acaf8 100644 --- a/common/source/EventThread.cpp +++ b/common/source/EventThread.cpp @@ -87,7 +87,20 @@ void EventThread::threadExecutor() m_lock.unlock(); if (func) - func(); + { + try + { + func(); + } + catch (const std::exception &e) + { + RIALTO_COMMON_LOG_ERROR("Exception thrown by event thread callback: %s", e.what()); + } + catch (...) + { + RIALTO_COMMON_LOG_ERROR("Unknown exception thrown by event thread callback"); + } + } m_lock.lock(); } diff --git a/media/server/gstplayer/source/WorkerThread.cpp b/media/server/gstplayer/source/WorkerThread.cpp index 7c065051f..e91e3c06c 100644 --- a/media/server/gstplayer/source/WorkerThread.cpp +++ b/media/server/gstplayer/source/WorkerThread.cpp @@ -97,7 +97,18 @@ void WorkerThread::taskHandler() while (m_isTaskThreadActive) { std::unique_ptr task = waitForTask(); - task->execute(); + try + { + task->execute(); + } + catch (const std::exception &e) + { + RIALTO_SERVER_LOG_ERROR("Exception thrown by task on the worker thread: %s", e.what()); + } + catch (...) + { + RIALTO_SERVER_LOG_ERROR("Unknown exception thrown by task on the worker thread"); + } } } diff --git a/media/server/main/source/MainThread.cpp b/media/server/main/source/MainThread.cpp index 21800c6a0..c1ed69654 100644 --- a/media/server/main/source/MainThread.cpp +++ b/media/server/main/source/MainThread.cpp @@ -89,7 +89,18 @@ void MainThread::mainThreadLoop() const std::shared_ptr kTaskInfo = waitForTask(); if (m_registeredClients.find(kTaskInfo->clientId) != m_registeredClients.end()) { - kTaskInfo->task(); + try + { + kTaskInfo->task(); + } + catch (const std::exception &e) + { + RIALTO_SERVER_LOG_ERROR("Exception thrown by task on the main thread: %s", e.what()); + } + catch (...) + { + RIALTO_SERVER_LOG_ERROR("Unknown exception thrown by task on the main thread"); + } } else {