diff --git a/asyncgit/src/error.rs b/asyncgit/src/error.rs index ffd0bd89..cd27e116 100644 --- a/asyncgit/src/error.rs +++ b/asyncgit/src/error.rs @@ -4,6 +4,72 @@ use std::{ }; use thiserror::Error; +/// +#[derive(Error, Debug)] +pub enum GixError { + /// + #[error("gix::discover error: {0}")] + Discover(#[from] Box), + + /// + #[error("gix::head::peel::to_commit error: {0}")] + HeadPeelToCommit(#[from] gix::head::peel::to_commit::Error), + + /// + #[error("gix::object::find::existing::with_conversion::Error error: {0}")] + ObjectFindExistingWithConversionError( + #[from] gix::object::find::existing::with_conversion::Error, + ), + + /// + #[error("gix::objs::decode::Error error: {0}")] + ObjsDecode(#[from] gix::objs::decode::Error), + + /// + #[error("gix::pathspec::init::Error error: {0}")] + PathspecInit(#[from] Box), + + /// + #[error("gix::reference::find::existing error: {0}")] + ReferenceFindExisting( + #[from] gix::reference::find::existing::Error, + ), + + /// + #[error("gix::reference::head_tree_id::Error error: {0}")] + ReferenceHeadTreeId(#[from] gix::reference::head_tree_id::Error), + + /// + #[error("gix::revision::walk error: {0}")] + RevisionWalk(#[from] gix::revision::walk::Error), + + /// + #[error("gix::status::Error error: {0}")] + Status(#[from] Box), + + /// + #[error("gix::status::index_worktree::Error error: {0}")] + StatusIndexWorktree( + #[from] Box, + ), + + /// + #[error("gix::status::into_iter::Error error: {0}")] + StatusIntoIter(#[from] Box), + + /// + #[error("gix::status::iter::Error error: {0}")] + StatusIter(#[from] Box), + + /// + #[error("gix::status::tree_index::Error error: {0}")] + StatusTreeIndex(#[from] Box), + + /// + #[error("gix::worktree::open_index::Error error: {0}")] + WorktreeOpenIndex(#[from] Box), +} + /// #[derive(Error, Debug)] pub enum Error { @@ -96,70 +162,8 @@ pub enum Error { Sign(#[from] crate::sync::sign::SignError), /// - #[error("gix::discover error: {0}")] - GixDiscover(#[from] Box), - - /// - #[error("gix::reference::find::existing error: {0}")] - GixReferenceFindExisting( - #[from] gix::reference::find::existing::Error, - ), - - /// - #[error("gix::head::peel::to_commit error: {0}")] - GixHeadPeelToCommit(#[from] gix::head::peel::to_commit::Error), - - /// - #[error("gix::revision::walk error: {0}")] - GixRevisionWalk(#[from] gix::revision::walk::Error), - - /// - #[error("gix::objs::decode::Error error: {0}")] - GixObjsDecode(#[from] gix::objs::decode::Error), - - /// - #[error("gix::object::find::existing::with_conversion::Error error: {0}")] - GixObjectFindExistingWithConversionError( - #[from] gix::object::find::existing::with_conversion::Error, - ), - - /// - #[error("gix::pathspec::init::Error error: {0}")] - GixPathspecInit(#[from] Box), - - /// - #[error("gix::reference::head_tree_id::Error error: {0}")] - GixReferenceHeadTreeId( - #[from] gix::reference::head_tree_id::Error, - ), - - /// - #[error("gix::status::Error error: {0}")] - GixStatus(#[from] Box), - - /// - #[error("gix::status::iter::Error error: {0}")] - GixStatusIter(#[from] Box), - - /// - #[error("gix::status::into_iter::Error error: {0}")] - GixStatusIntoIter(#[from] Box), - - /// - #[error("gix::status::index_worktree::Error error: {0}")] - GixStatusIndexWorktree( - #[from] Box, - ), - - /// - #[error("gix::status::tree_index::Error error: {0}")] - GixStatusTreeIndex(#[from] Box), - - /// - #[error("gix::worktree::open_index::Error error: {0}")] - GixWorktreeOpenIndex( - #[from] Box, - ), + #[error("gix error:{0}")] + Gix(#[from] GixError), /// #[error("amend error: config commit.gpgsign=true detected.\ngpg signing is not supported for amending non-last commits")] @@ -189,50 +193,138 @@ impl From> for Error { } } +impl From for GixError { + fn from(error: gix::discover::Error) -> Self { + Self::Discover(Box::new(error)) + } +} + impl From for Error { fn from(error: gix::discover::Error) -> Self { - Self::GixDiscover(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for Error { + fn from(error: gix::head::peel::to_commit::Error) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From + for Error +{ + fn from( + error: gix::object::find::existing::with_conversion::Error, + ) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From for Error { + fn from(error: gix::objs::decode::Error) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::pathspec::init::Error) -> Self { + Self::PathspecInit(Box::new(error)) } } impl From for Error { fn from(error: gix::pathspec::init::Error) -> Self { - Self::GixPathspecInit(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for Error { + fn from(error: gix::reference::find::existing::Error) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From for Error { + fn from(error: gix::reference::head_tree_id::Error) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From for Error { + fn from(error: gix::revision::walk::Error) -> Self { + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::status::Error) -> Self { + Self::Status(Box::new(error)) } } impl From for Error { fn from(error: gix::status::Error) -> Self { - Self::GixStatus(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::status::iter::Error) -> Self { + Self::StatusIter(Box::new(error)) } } impl From for Error { fn from(error: gix::status::iter::Error) -> Self { - Self::GixStatusIter(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::status::into_iter::Error) -> Self { + Self::StatusIntoIter(Box::new(error)) } } impl From for Error { fn from(error: gix::status::into_iter::Error) -> Self { - Self::GixStatusIntoIter(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::status::index_worktree::Error) -> Self { + Self::StatusIndexWorktree(Box::new(error)) } } impl From for Error { fn from(error: gix::status::index_worktree::Error) -> Self { - Self::GixStatusIndexWorktree(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::status::tree_index::Error) -> Self { + Self::StatusTreeIndex(Box::new(error)) } } impl From for Error { fn from(error: gix::status::tree_index::Error) -> Self { - Self::GixStatusTreeIndex(Box::new(error)) + Self::Gix(GixError::from(error)) + } +} + +impl From for GixError { + fn from(error: gix::worktree::open_index::Error) -> Self { + Self::WorktreeOpenIndex(Box::new(error)) } } impl From for Error { fn from(error: gix::worktree::open_index::Error) -> Self { - Self::GixWorktreeOpenIndex(Box::new(error)) + Self::Gix(GixError::from(error)) } }