1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-09-11 15:05:30 +03:00

feat(changelog): make rendering errors more verbose

closes #542
This commit is contained in:
Orhun Parmaksız 2024-03-13 21:03:27 +03:00
parent 5f2d0f04fe
commit 7ee3c860af
No known key found for this signature in database
GPG Key ID: F83424824B3E4B90
2 changed files with 12 additions and 2 deletions

View File

@ -40,6 +40,9 @@ pub enum Error {
/// Error that may occur while rendering the template.
#[error("Template render error:\n{0}")]
TemplateRenderError(String),
/// Error that may occur while rendering the template.
#[error("Template render error:\n{0}\n{1}")]
TemplateRenderDetailedError(String, String),
/// Error that may occur during more general template operations.
#[error("Template error: `{0}`")]
TemplateError(#[from] tera::Error),

View File

@ -163,8 +163,15 @@ impl Template {
Ok(v)
}
Err(e) => {
return if let Some(error_source) = e.source() {
Err(Error::TemplateRenderError(error_source.to_string()))
return if let Some(source1) = e.source() {
if let Some(source2) = source1.source() {
Err(Error::TemplateRenderDetailedError(
source1.to_string(),
source2.to_string(),
))
} else {
Err(Error::TemplateRenderError(source1.to_string()))
}
} else {
Err(Error::TemplateError(e))
};