Skip to content

Commit

Permalink
Merge pull request #240 from epics-containers/bugfix
Browse files Browse the repository at this point in the history
improve error reporting in support generate-schema. fixes #235
  • Loading branch information
gilesknap authored Jun 24, 2024
2 parents 2c6f498 + ec96ec6 commit ffcae40
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ibek/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit ffcae40

Please sign in to comment.