diff --git a/src/caosadvancedtools/cfood.py b/src/caosadvancedtools/cfood.py index d2e30de5a99faa1d4c9f6d4753f656ede49b0c46..0eb826321d9889c6d8fcc09f6208bb56b9d3066e 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 b97e507e2c1577fd8d56c7aca5f0adc625ae1b31..52552bd389bf5abfcb4d96d25456b12593ee16c8 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")