From 82a4a12c0133170f873fc617f13fb61d8df99973 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 25 Feb 2022 11:28:18 -0700 Subject: [PATCH] if TOML header fails to parse, don't 500 the entire site Signed-off-by: Matt Butcher --- src/content.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/content.rs b/src/content.rs index 8aafa75..166f244 100644 --- a/src/content.rs +++ b/src/content.rs @@ -83,9 +83,17 @@ pub fn all_pages(dir: PathBuf, show_unpublished: bool) -> anyhow::Result() { + Ok(content) => { + if show_unpublished || content.published { + contents.insert(f.to_string_lossy().to_string(), content.into()); + } + }, + Err(e) => { + // If a parse fails, don't take down the entire site. Just skip this piece of content. + eprintln!("File {:?}: {}", &f, e); + continue + } } } Ok(contents)