X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/60307a9a3a39dccf652c9d9b4348e44db1e67627..f7f4335199beaad56d9c962ac84e92a3f78907a6:/src/generator/rss.rs?ds=sidebyside diff --git a/src/generator/rss.rs b/src/generator/rss.rs index 1aac73d..6a13bb8 100644 --- a/src/generator/rss.rs +++ b/src/generator/rss.rs @@ -1,5 +1,5 @@ use std::fs::write; -use std::io::Result; +use std::io::{Error, ErrorKind::Other, Result}; use std::path::PathBuf; use crate::template::{find, parse, TemplateContext}; @@ -8,8 +8,9 @@ const FILENAME: &str = "feed.xml"; pub fn generate(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> { match find(template_directory, FILENAME) { Some(template) => { - let parsed_template = parse(&template); - let rendered_template = parsed_template.render(context); + let parsed_template = parse(&template) + .ok_or_else(|| Error::new(Other, "Unable to parse RSS template"))?; + let rendered_template = parsed_template.render(context)?; let location = target.join(FILENAME); write(location, rendered_template)?; },