Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve error reporting in support generate-schema. fixes #235 #240

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading