From f7a303dd2c34e3e74136462b607efb97ab6b62bf Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Mon, 30 Aug 2021 14:01:22 +0200
Subject: [PATCH] Improve error handling

---
 .../libraries/armem_gui/MemoryViewer.cpp      | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp b/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp
index c56cc1077..6e2bbb30b 100644
--- a/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp
+++ b/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp
@@ -69,7 +69,6 @@ namespace armarx::armem::gui
         processQueryResultTimer->setInterval(1000 / 60);  // Keep this stable.
         processQueryResultTimer->start();
 
-
         // Memory View
         memoryGroup = new armem::gui::MemoryGroupBox();
         armarx::gui::replaceWidget(memoryGroupBox, memoryGroup, memoryGroupBoxParentLayout);
@@ -133,7 +132,7 @@ namespace armarx::armem::gui
 
     void MemoryViewer::onConnect(ManagedIceObject& component)
     {
-        if (!mnsName.empty())
+        if (not mnsName.empty())
         {
             armem::mns::MemoryNameSystemInterfacePrx mnsProxy;
             component.getProxy(mnsProxy, mnsName);
@@ -143,7 +142,7 @@ namespace armarx::armem::gui
             memoryReaders = mns.getAllReaders(update);
         }
         // DebugObserver is optional (check for null on every call)
-        if (!debugObserverName.empty())
+        if (not debugObserverName.empty())
         {
             component.getProxy(debugObserver, debugObserverName, false, "", false);
         }
@@ -381,13 +380,13 @@ namespace armarx::armem::gui
         const armem::wm::Memory* data = getSingleMemoryData(selectedID.memoryName);
         if (data)
         {
-            if (!selectedID.hasEntityName())
+            if (not selectedID.hasEntityName())
             {
                 return;
             }
             armem::MemoryID id = selectedID;
             const armem::wm::EntitySnapshot* snapshot = nullptr;
-            if (!id.hasTimestamp())
+            if (not id.hasTimestamp())
             {
                 const armem::wm::Entity& entity = data->getEntity(id);
                 if (entity.empty())
@@ -397,9 +396,9 @@ namespace armarx::armem::gui
                 snapshot = &entity.getLatestSnapshot();
                 id.timestamp = snapshot->time();
             }
-            if (!id.hasInstanceIndex())
+            if (not id.hasInstanceIndex())
             {
-                if (!snapshot)
+                if (not snapshot)
                 {
                     try
                     {
@@ -509,7 +508,14 @@ namespace armarx::armem::gui
 
         if (debugObserver)
         {
-            debugObserver->setDebugDatafield(Logging::tag.tagName, "GUI Update [ms]", new Variant(GuiUpdate.toMilliSecondsDouble()));
+            try
+            {
+                debugObserver->setDebugDatafield(Logging::tag.tagName, "GUI Update [ms]", new Variant(GuiUpdate.toMilliSecondsDouble()));
+            }
+            catch (const Ice::Exception&)
+            {
+                // Ignore ...
+            }
         }
     }
 
-- 
GitLab