From c183f80a229c25d59656d4c910f1c771ea0fba01 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 8 Dec 2022 21:56:56 +0100 Subject: [PATCH] Cleanup some of the git error variants Signed-off-by: Alexis Sellier --- radicle/src/identity.rs | 8 ++++---- radicle/src/identity/doc.rs | 9 +++++---- radicle/src/rad.rs | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/radicle/src/identity.rs b/radicle/src/identity.rs index 9766323e..89f949a5 100644 --- a/radicle/src/identity.rs +++ b/radicle/src/identity.rs @@ -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)] diff --git a/radicle/src/identity/doc.rs b/radicle/src/identity/doc.rs index dac303d9..706ea375 100644 --- a/radicle/src/identity/doc.rs +++ b/radicle/src/identity/doc.rs @@ -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, } } diff --git a/radicle/src/rad.rs b/radicle/src/rad.rs index cd45303c..b4b466d4 100644 --- a/radicle/src/rad.rs +++ b/radicle/src/rad.rs @@ -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}")]