radicle: Remove unused error variants

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-12-08 16:15:45 +01:00
parent 98c1566109
commit 8735719ecc
No known key found for this signature in database
2 changed files with 3 additions and 17 deletions

View File

@ -2,7 +2,6 @@ mod id;
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use std::fmt::{self, Write as _}; use std::fmt::{self, Write as _};
use std::io;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::Deref; use std::ops::Deref;
use std::path::Path; use std::path::Path;
@ -42,27 +41,18 @@ pub const MAX_DELEGATES: usize = 255;
pub enum DocError { pub enum DocError {
#[error("json: {0}")] #[error("json: {0}")]
Json(#[from] serde_json::Error), Json(#[from] serde_json::Error),
#[error("i/o: {0}")]
Io(#[from] io::Error),
#[error("verification: {0}")]
Verification(#[from] VerificationError),
#[error("payload: {0}")]
Payload(#[from] PayloadError),
#[error("git: {0}")] #[error("git: {0}")]
Git(#[from] git::Error), Git(#[from] git::Error),
#[error("git: {0}")] #[error("git: {0}")]
RawGit(#[from] git2::Error), RawGit(#[from] git2::Error),
#[error("storage: {0}")] #[error("storage: {0}")]
Storage(#[from] storage::Error), Storage(#[from] storage::Error),
#[error("git: reference `{0}` was not found")]
NotFound(git::RefString),
} }
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::NotFound(_) => true,
Self::Git(git::Error::NotFound(_)) => true, Self::Git(git::Error::NotFound(_)) => true,
Self::Git(git::Error::Git(e)) if git::is_not_found_err(e) => true, Self::Git(git::Error::Git(e)) if git::is_not_found_err(e) => true,
_ => false, _ => false,

View File

@ -11,7 +11,7 @@ use radicle_cob::{self as cob, change};
use crate::git; use crate::git;
use crate::identity; use crate::identity;
use crate::identity::project::{Identity, IdentityError, Project}; use crate::identity::project::{Identity, IdentityError, Project, VerificationError};
use crate::identity::{Doc, Id}; use crate::identity::{Doc, Id};
use crate::storage::refs; use crate::storage::refs;
use crate::storage::refs::{Refs, SignedRefs}; use crate::storage::refs::{Refs, SignedRefs};
@ -43,8 +43,8 @@ pub enum ProjectError {
Doc(#[from] identity::project::DocError), Doc(#[from] identity::project::DocError),
#[error("payload error: {0}")] #[error("payload error: {0}")]
Payload(#[from] identity::project::PayloadError), Payload(#[from] identity::project::PayloadError),
#[error("identity verification error: {0}")] #[error("verification error: {0}")]
Verify(#[from] identity::project::VerificationError), Verification(#[from] VerificationError),
#[error("git: {0}")] #[error("git: {0}")]
Git(#[from] git2::Error), Git(#[from] git2::Error),
#[error("git: {0}")] #[error("git: {0}")]
@ -176,12 +176,8 @@ pub enum VerifyError {
InvalidRemote(RemoteId), InvalidRemote(RemoteId),
#[error("invalid target `{2}` for reference `{1}` of remote `{0}`")] #[error("invalid target `{2}` for reference `{1}` of remote `{0}`")]
InvalidRefTarget(RemoteId, RefString, git2::Oid), InvalidRefTarget(RemoteId, RefString, git2::Oid),
#[error("invalid reference")]
InvalidRef,
#[error("invalid identity: {0}")] #[error("invalid identity: {0}")]
InvalidIdentity(#[from] IdentityError), InvalidIdentity(#[from] IdentityError),
#[error("ref error: {0}")]
Ref(#[from] git::RefError),
#[error("refs error: {0}")] #[error("refs error: {0}")]
Refs(#[from] refs::Error), Refs(#[from] refs::Error),
#[error("unknown reference `{1}` in remote `{0}`")] #[error("unknown reference `{1}` in remote `{0}`")]