diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-12-27 14:09:52 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-12-27 14:09:52 +0000 |
commit | a0df28bed44def6cddb342d0331313a298bdf00c (patch) | |
tree | a3fa280689ff046ba21fad99880925cf575f1204 /src | |
parent | e8082fef03bd04042dad3fb2d0513587c54874ab (diff) | |
download | subplot-a0df28bed44def6cddb342d0331313a298bdf00c.tar.gz |
codegen: Refuse to generate code if the specified template is not present
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.rs | 3 | ||||
-rw-r--r-- | src/error.rs | 9 |
2 files changed, 12 insertions, 0 deletions
@@ -559,6 +559,9 @@ pub fn codegen(filename: &Path, output: &Path, template: Option<&str>) -> Result .unwrap_or_else(|| doc.template())? .to_string(); event!(Level::TRACE, ?template); + if !doc.meta().templates().any(|t| t == template) { + return Err(SubplotError::TemplateSupportNotPresent); + } if !doc.check_named_files_exist(&template)? || !doc.check_matched_steps_have_impl(&template) || !doc.check_embedded_files_are_used(&template)? diff --git a/src/error.rs b/src/error.rs index ec88733..bcee4ff 100644 --- a/src/error.rs +++ b/src/error.rs @@ -125,6 +125,15 @@ pub enum SubplotError { #[error("document has more than one template possibility")] AmbiguousTemplate, + /// Document does not support the requested template + /// + /// The document YAML metadata does not specify support for the + /// stated template. + /// + /// To fix, specify a template which is provided for in the document. + #[error("document lacks specified template support")] + TemplateSupportNotPresent, + /// Pandoc AST is not JSON /// /// Subplot acts as a Pandoc filter, and as part of that Pandoc |