From 4c88ff22717e87856cfb3f195fe88e2a4812fd6a Mon Sep 17 00:00:00 2001
From: "i.nueske" <i.nueske@indiscale.com>
Date: Mon, 16 Dec 2024 17:29:42 +0100
Subject: [PATCH] MNT: Use specific exception types instead of Exception

---
 src/caosadvancedtools/cfood.py         | 3 ++-
 src/caosadvancedtools/models/parser.py | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/caosadvancedtools/cfood.py b/src/caosadvancedtools/cfood.py
index d2e30de5..0eb82632 100644
--- a/src/caosadvancedtools/cfood.py
+++ b/src/caosadvancedtools/cfood.py
@@ -572,6 +572,7 @@ def assure_parents_are(entity, parents, to_be_updated=None,
     the new parents and the old ones are discarded.
 
     Note that parent matching occurs based on names.
+    If a parent does not have a name, a ValueError is raised.
 
     If the list to_be_updated is supplied, the entity is added to
     the list in order to indicate, that the entity `entity` should be updated.
@@ -586,7 +587,7 @@ def assure_parents_are(entity, parents, to_be_updated=None,
     for i, e in enumerate(parents):
         if isinstance(e, db.Entity):
             if e.name is None:
-                raise Exception("Entity should have name")
+                raise ValueError("Entity should have name")
         else:
             parents[i] = db.Entity(name=e)
 
diff --git a/src/caosadvancedtools/models/parser.py b/src/caosadvancedtools/models/parser.py
index b97e507e..52552bd3 100644
--- a/src/caosadvancedtools/models/parser.py
+++ b/src/caosadvancedtools/models/parser.py
@@ -286,6 +286,12 @@ debug : bool, optional
         existing_model : dict, optional
           An existing model to which the created model shall be added.
 
+        Raises
+        ------
+        ValueError
+          If model_dict is not a dict, model_dict["extern"] contains an
+          unknown entry, or there is an unknown entry in model_dict.
+
         Returns
         -------
         out : data_model.DataModel
@@ -320,7 +326,7 @@ debug : bool, optional
                         f"FIND {role} WITH name=\"{name}\"", unique=True)
                     break
             else:
-                raise Exception("Did not find {}".format(name))
+                raise ValueError("Did not find {}".format(name))
 
         ymlmodel.pop("extern")
 
-- 
GitLab