From ec96ec6d0a1b2cfe5bf790bc3c93c135dda7afd3 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Mon, 24 Jun 2024 09:43:57 +0000 Subject: [PATCH] improve error reporting in support generate-schema --- src/ibek/entity_factory.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ibek/entity_factory.py b/src/ibek/entity_factory.py index 03e87360..852c1e76 100644 --- a/src/ibek/entity_factory.py +++ b/src/ibek/entity_factory.py @@ -9,7 +9,7 @@ from typing import Annotated, Any, Dict, List, Literal, Tuple, Type from pydantic import Field, create_model -from pydantic_core import PydanticUndefined, ValidationError +from pydantic_core import PydanticUndefined from ruamel.yaml.main import YAML from ibek.globals import JINJA @@ -40,19 +40,19 @@ def make_entity_models(self, entity_model_yaml: List[Path]) -> List[Type[Entity] from their EntityModel entries """ - for entity_model in entity_model_yaml: - support_dict = YAML(typ="safe").load(entity_model) + try: + for entity_model in entity_model_yaml: + support_dict = YAML(typ="safe").load(entity_model) - try: Support.model_validate(support_dict) # deserialize the support module yaml file support = Support(**support_dict) # make Entity classes described in the support module yaml file self._make_entity_models(support) - except ValidationError: - print(f"PYDANTIC VALIDATION ERROR IN {entity_model}") - raise + except Exception: + print(f"VALIDATION ERROR READING {entity_model}") + raise return list(self._entity_models.values())