X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/6352ebb0eb4cb83240c6d4998e0ef1375b041191..c4b892b16fb92c7d89eaee0b1588c52c8836216b:/src/archiver/gopher.rs?ds=sidebyside diff --git a/src/archiver/gopher.rs b/src/archiver/gopher.rs index 820e4d1..28f4f46 100644 --- a/src/archiver/gopher.rs +++ b/src/archiver/gopher.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 = "index.gph"; pub fn archive(_: &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 Gopher Archive template"))?; + let rendered_template = parsed_template.render(context)?; let location = target.join(FILENAME); write(location, rendered_template)?; },