From 2a706cf5285f247d44d8ed35f7cf73062df3cf0d Mon Sep 17 00:00:00 2001 From: InioX Date: Tue, 12 Dec 2023 19:42:00 +0100 Subject: [PATCH] feat: add span of file in template render error --- src/util/template.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/template.rs b/src/util/template.rs index 21a986d..997eb6b 100644 --- a/src/util/template.rs +++ b/src/util/template.rs @@ -2,6 +2,7 @@ use color_eyre::eyre::ContextCompat; use color_eyre::eyre::WrapErr; use color_eyre::Help; use color_eyre::{eyre::Result, Report}; +use color_eyre::SectionExt; use colorsys::Hsl; use serde::{Deserialize, Serialize}; @@ -211,10 +212,11 @@ impl Template { )); } - data = engine.template(name) - .render(upon::value!{ colors: &colors, image: image, custom: &custom, }) - .to_string()?; - + let data = engine.template(name).render(upon::value!{ colors: &colors, image: image, custom: &custom, }).to_string().map_err(|error| { + let message = format!("{:#}", error); + Report::new(error).wrap_err(message) + })?; + let mut output_file = OpenOptions::new() .create(true) .truncate(true)