Skip to content

Commit

Permalink
fix(taxonomies): fix error messages (#2591)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
samueltardieu authored Aug 1, 2024
1 parent 1834dc1 commit 88bd972
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions components/templates/src/global_fns/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());
Expand All @@ -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()
);
}
};

Expand Down

0 comments on commit 88bd972

Please sign in to comment.