Cleanup some of the git error variants

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-12-08 21:56:56 +01:00
parent d309f593b1
commit c183f80a22
No known key found for this signature in database
3 changed files with 11 additions and 10 deletions

View File

@ -28,11 +28,13 @@ pub struct Trusted;
#[derive(Error, Debug)]
pub enum IdentityError {
#[error("git: {0}")]
GitRaw(#[from] git2::Error),
Git(#[from] git2::Error),
#[error("git: {0}")]
Git(#[from] git::Error),
GitExt(#[from] git::Error),
#[error("root hash `{0}` does not match project")]
MismatchedRoot(Oid),
#[error("the document root is missing")]
MissingRoot,
#[error("commit signature for {0} is invalid: {1}")]
InvalidSignature(PublicKey, crypto::Error),
#[error("commit message for {0} is invalid")]
@ -43,8 +45,6 @@ pub enum IdentityError {
QuorumNotReached(usize, usize),
#[error("identity document error: {0}")]
Doc(#[from] doc::DocError),
#[error("the document root is missing")]
MissingRoot,
}
#[derive(Clone, Debug, PartialEq, Eq)]

View File

@ -41,17 +41,18 @@ pub enum DocError {
#[error("invalid threshold `{0}`: {1}")]
Threshold(usize, &'static str),
#[error("git: {0}")]
Git(#[from] git::Error),
GitExt(#[from] git::Error),
#[error("git: {0}")]
RawGit(#[from] git2::Error),
Git(#[from] git2::Error),
}
impl DocError {
/// Whether this error is caused by the document not being found.
pub fn is_not_found(&self) -> bool {
match self {
Self::Git(git::Error::NotFound(_)) => true,
Self::Git(git::Error::Git(e)) if git::is_not_found_err(e) => true,
Self::GitExt(git::Error::NotFound(_)) => true,
Self::GitExt(git::Error::Git(e)) if git::is_not_found_err(e) => true,
Self::Git(err) if git::is_not_found_err(err) => true,
_ => false,
}
}

View File

@ -88,9 +88,9 @@ pub enum ForkError {
#[error("ref string: {0}")]
RefString(#[from] git::fmt::Error),
#[error("git: {0}")]
GitRaw(#[from] git2::Error),
Git(#[from] git2::Error),
#[error("git: {0}")]
Git(#[from] git::Error),
GitExt(#[from] git::Error),
#[error("storage: {0}")]
Storage(#[from] storage::Error),
#[error("payload: {0}")]