Skip to content

Commit

Permalink
feat(changelog): make rendering errors more verbose
Browse files Browse the repository at this point in the history
closes #542
  • Loading branch information
orhun committed Mar 13, 2024
1 parent 5f2d0f0 commit 7ee3c86
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions git-cliff-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 9 additions & 2 deletions git-cliff-core/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
};
Expand Down

0 comments on commit 7ee3c86

Please sign in to comment.