From 88bd972cc4809f8aeb7847481166b89da2aff8d7 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Thu, 1 Aug 2024 22:33:12 +0200 Subject: [PATCH] fix(taxonomies): fix error messages (#2591) - Some error messages refer to `get_taxonomy_term_by_name` instead of `get_taxonomy_term` - If a term cannot be found in a taxonomy, the error message erroneously pretends that the taxonomy itself is unknown instead of the term. --- .../templates/src/global_fns/content.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/components/templates/src/global_fns/content.rs b/components/templates/src/global_fns/content.rs index 17183bb63..4ad6fd18d 100644 --- a/components/templates/src/global_fns/content.rs +++ b/components/templates/src/global_fns/content.rs @@ -313,12 +313,9 @@ impl TeraFn for GetTaxonomyTerm { ) .unwrap_or(true); - let lang = optional_arg!( - String, - args.get("lang"), - "`get_taxonomy_term_by_name`: `lang` must be a string" - ) - .unwrap_or_else(|| self.default_lang.clone()); + let lang = + optional_arg!(String, args.get("lang"), "`get_taxonomy_term`: `lang` must be a string") + .unwrap_or_else(|| self.default_lang.clone()); let tax: &Taxonomy = match (self.taxonomies.get(&format!("{}-{}", kind, lang)), required) { (Some(t), _) => t, @@ -327,7 +324,7 @@ impl TeraFn for GetTaxonomyTerm { } (None, true) => { return Err(format!( - "`get_taxonomy_term_by_name` received an unknown taxonomy as kind: {}", + "`get_taxonomy_term` received an unknown taxonomy as kind: {}", kind ) .into()); @@ -340,11 +337,9 @@ impl TeraFn for GetTaxonomyTerm { return Ok(Value::Null); } (None, true) => { - return Err(format!( - "`get_taxonomy_term_by_name` received an unknown taxonomy as kind: {}", - kind - ) - .into()); + return Err( + format!("`get_taxonomy_term` received an unknown term: {}", term).into() + ); } };