From e2e589dc1709b284832faa9baa30420783dfc674 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Sun, 3 Aug 2025 10:32:02 -0400 Subject: [PATCH] ExceptionInd: Remove duplicate invocations --- smocore/componentThread.cpp | 10 ++++++---- smocore/marionette/marionette.cpp | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/smocore/componentThread.cpp b/smocore/componentThread.cpp index 9b5c8f3..aa2bca4 100644 --- a/smocore/componentThread.cpp +++ b/smocore/componentThread.cpp @@ -108,24 +108,26 @@ void ComponentThread::main(ComponentThread& self) */ for (self.keepLooping = true; self.keepLooping;) { + bool sendExceptionInd = false; + try { self.getIoService().reset(); self.getIoService().run(); } catch (const std::exception& e) { + sendExceptionInd = true; std::cerr << self.name << ":" << __func__ << ": Exception occurred: " << e.what() << "\n"; - - mrntt::mrntt->exceptionInd(self); } catch (...) { + sendExceptionInd = true; std::cerr << self.name << ":" << __func__ << ": Unknown exception occurred" << "\n"; - - mrntt::mrntt->exceptionInd(self); } + + if (sendExceptionInd) { mrntt::mrntt->exceptionInd(self); } } std::cout << self.name << ":" << __func__ << ": Exited event loop" << "\n"; diff --git a/smocore/marionette/marionette.cpp b/smocore/marionette/marionette.cpp index 9fcacdc..b77ca63 100644 --- a/smocore/marionette/marionette.cpp +++ b/smocore/marionette/marionette.cpp @@ -106,20 +106,25 @@ void ComponentThread::marionetteMain(ComponentThread& self) */ for (self.keepLooping = true; self.keepLooping;) { + bool sendExceptionInd = false; try { self.getIoService().reset(); self.getIoService().run(); } catch (const std::exception& e) { + sendExceptionInd = true; std::cerr << self.name << ":" << __func__ << ": Exception occurred: " << e.what() << "\n"; } catch (...) { + sendExceptionInd = true; std::cerr << self.name << ":" << __func__ << ": Unknown exception occurred" << "\n"; } + + if (sendExceptionInd) { self.exceptionInd(self); } } std::cout << __func__ << ": Exited event loop" << "\n";