From da3653b962f2edf572e07e7664a9fed84ebd5ae3 Mon Sep 17 00:00:00 2001 From: "Charles A. Daniels" Date: Mon, 2 Jan 2023 10:41:56 -0500 Subject: [PATCH] zettle: print paths with invalid frontmatter instead of crashing --- modules/zettle/zettle.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/zettle/zettle.py b/modules/zettle/zettle.py index db414c7..e995ac6 100755 --- a/modules/zettle/zettle.py +++ b/modules/zettle/zettle.py @@ -130,7 +130,12 @@ def extract_frontmatter(path): if in_frontmatter: frontmatter_raw += line + "\n" - frontmatter = yaml.safe_load(frontmatter_raw) + frontmatter = None + try: + frontmatter = yaml.safe_load(frontmatter_raw) + except Exception as e: + sys.stderr.write("Failed to load frontmatter from path: '{}': {}\n".format(path, e)) + if frontmatter is None: frontmatter = {} return frontmatter -- 2.45.2