fix: improve error handling when frontmatter malformed

This commit is contained in:
Nathaniel Landau
2023-03-03 21:02:32 -05:00
parent bd4b94aefa
commit bf869cfc15
5 changed files with 53 additions and 13 deletions

View File

@@ -240,7 +240,11 @@ class Frontmatter:
return {}
yaml = YAML(typ="safe")
frontmatter: dict = yaml.load(frontmatter_block)
yaml.allow_unicode = False
try:
frontmatter: dict = yaml.load(frontmatter_block)
except Exception as e: # noqa: BLE001
raise AttributeError(e) from e
for k in frontmatter:
if frontmatter[k] is None: