diff --git a/mkdocs.yml b/mkdocs.yml
index 08fd23ef68..d0738c7e29 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -116,6 +116,7 @@ plugins:
             - css/watermark.css
   - macros:
       module_name: tools/mkdocs_macros_bids/main
+      on_error_fail: true
   - redirects:
       redirect_maps:
         "01-introduction.md": "introduction.md"
diff --git a/tools/schemacode/src/bidsschematools/types/namespace.py b/tools/schemacode/src/bidsschematools/types/namespace.py
index e2c37eee40..52f21e2d0c 100644
--- a/tools/schemacode/src/bidsschematools/types/namespace.py
+++ b/tools/schemacode/src/bidsschematools/types/namespace.py
@@ -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