Skip to content

Commit

Permalink
refactor(error): use custom error message for GroupError
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jun 20, 2021
1 parent 40a9562 commit 1be66ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions git-cliff-core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,19 @@ impl Commit<'_> {
self.group = parser.group.as_ref().cloned();
return Ok(self);
} else {
return Err(AppError::GroupError);
return Err(AppError::GroupError(String::from(
"Skipping commit",
)));
}
}
}
}
if !filter {
Ok(self)
} else {
Err(AppError::GroupError)
Err(AppError::GroupError(String::from(
"Commit does not belong to any group",
)))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions git-cliff-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub enum Error {
/// error.
#[error("Cannot parse the commit: `{0}`")]
ParseError(#[from] git_conventional::Error),
/// When commit's not belong to any group we throw this error.
#[error("Commit does not belong to any group")]
GroupError,
/// Error that may occur while grouping commits.
#[error("Grouping error: `{0}`")]
GroupError(String),
/// Error that may occur while template operations such as parse and render.
#[error("Template error: `{0}`")]
TemplateError(#[from] tera::Error),
Expand Down

0 comments on commit 1be66ee

Please sign in to comment.