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

View File

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

View File

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