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

[FIX] graceful error when failing to load invalid yml #2009

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ plugins:
- css/watermark.css
- macros:
module_name: tools/mkdocs_macros_bids/main
on_error_fail: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this extra check because the wesbite would still build but with broken pages which is not something we want

- redirects:
redirect_maps:
"01-introduction.md": "introduction.md"
Expand Down
5 changes: 4 additions & 1 deletion tools/schemacode/src/bidsschematools/types/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ def _read_yaml_dir(path: Path) -> dict:
if subpath.is_dir():
mapping[subpath.name] = _read_yaml_dir(subpath)
elif subpath.name.endswith("yaml"):
mapping[subpath.stem] = yaml.safe_load(subpath.read_text())
try:
mapping[subpath.stem] = yaml.safe_load(subpath.read_text())
except Exception as e:
raise ValueError(f"There was an error reading the file: {subpath}") from e
return mapping


Expand Down
Loading