From 683826988cdb66e368f8643c018bfbb22a0c7f71 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 29 Dec 2021 17:35:02 +0100
Subject: [PATCH] Assert

---
 GUI/Model/Group/GroupInfo.cpp    | 15 +++------------
 Tests/Unit/GUI/TestGroupItem.cpp |  5 ++---
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/GUI/Model/Group/GroupInfo.cpp b/GUI/Model/Group/GroupInfo.cpp
index 5fa27f53645..f4eabcf0ae8 100644
--- a/GUI/Model/Group/GroupInfo.cpp
+++ b/GUI/Model/Group/GroupInfo.cpp
@@ -13,17 +13,13 @@
 //  ************************************************************************************************
 
 #include "GUI/Model/Group/GroupInfo.h"
-#include "GUI/Util/Error.h"
+#include "Base/Util/Assert.h"
 
 GroupInfo::GroupInfo(bool is_sorted) : is_sorted(is_sorted) {}
 
 void GroupInfo::add(const QString& itemType, const QString& itemLabel)
 {
-    if (containsType(itemType))
-        throw Error("GroupInfo::add() -> Error. "
-                    "Model type '"
-                    + itemType + "' already exists.");
-
+    ASSERT(!containsType(itemType));
     m_info.push_back({itemType, itemLabel});
 
     if (is_sorted)
@@ -40,9 +36,7 @@ QString GroupInfo::defaultType() const
 
 void GroupInfo::setDefaultType(const QString& modelType)
 {
-    if (!containsType(modelType))
-        throw Error("GroupInfo::add() -> Error. No such type '" + modelType + "'");
-
+    ASSERT(containsType(modelType));
     m_defaultItemType = modelType;
 }
 
@@ -51,7 +45,6 @@ QStringList GroupInfo::itemTypes() const
     QStringList result;
     for (const auto& pair : m_info)
         result.append(pair.m_itemType);
-
     return result;
 }
 
@@ -60,7 +53,6 @@ QStringList GroupInfo::itemLabels() const
     QStringList result;
     for (const auto& pair : m_info)
         result.append(pair.m_itemLabel);
-
     return result;
 }
 
@@ -69,6 +61,5 @@ bool GroupInfo::containsType(const QString& itemType) const
     for (const auto& pair : m_info)
         if (itemType == pair.m_itemType)
             return true;
-
     return false;
 }
diff --git a/Tests/Unit/GUI/TestGroupItem.cpp b/Tests/Unit/GUI/TestGroupItem.cpp
index 97c725d2159..7e9a48b9afe 100644
--- a/Tests/Unit/GUI/TestGroupItem.cpp
+++ b/Tests/Unit/GUI/TestGroupItem.cpp
@@ -4,7 +4,6 @@
 #include "GUI/Model/Session/SessionModel.h"
 #include "GUI/Support/Type/VariantUtil.h"
 #include "GUI/Util/ComboProperty.h"
-#include "GUI/Util/Error.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include "Tests/Unit/GUI/Utils.h"
 
@@ -43,10 +42,10 @@ TEST_F(TestGroupItem, groupInfo)
                                                << "c_label2");
 
     // attempt to set non-existing default type
-    EXPECT_THROW(info.setDefaultType("XXX"), Error);
+    EXPECT_THROW(info.setDefaultType("XXX"), std::runtime_error);
 
     // attempt to add same info twice
-    EXPECT_THROW(info.add("CCC2", "c_label2"), Error);
+    EXPECT_THROW(info.add("CCC2", "c_label2"), std::runtime_error);
 }
 
 //! Checking that GroupProperty stays functional if displayName of currentItem is changed.
-- 
GitLab