#![allow(renamed_and_removed_lints, clippy::unknown_clippy_lints)] use std::{ num::TryFromIntError, path::StripPrefixError, string::FromUtf8Error, }; use thiserror::Error; /// #[derive(Error, Debug)] pub enum Error { /// #[error("`{0}`")] Generic(String), /// #[error("git: no head found")] NoHead, /// #[error("git: conflict during rebase")] RebaseConflict, /// #[error("git: remote url not found")] UnknownRemote, /// #[error("git: inconclusive remotes")] NoDefaultRemoteFound, /// #[error("git: work dir error")] NoWorkDir, /// #[error("git: uncommitted changes")] UncommittedChanges, /// #[error("git: can\u{2019}t run blame on a binary file")] NoBlameOnBinaryFile, /// #[error("binary file")] BinaryFile, /// #[error("io error:{0}")] Io(#[from] std::io::Error), /// #[error("git error:{0}")] Git(#[from] git2::Error), /// #[error("strip prefix error: {0}")] StripPrefix(#[from] StripPrefixError), /// #[error("utf8 error:{0}")] Utf8Conversion(#[from] FromUtf8Error), /// #[error("TryFromInt error:{0}")] IntConversion(#[from] TryFromIntError), /// #[error("EasyCast error:{0}")] EasyCast(#[from] easy_cast::Error), /// #[error("no parent of commit found")] NoParent, /// #[error("not on a branch")] NoBranch, /// #[error("rayon error: {0}")] ThreadPool(#[from] rayon_core::ThreadPoolBuildError), /// #[error("git hook error: {0}")] Hooks(#[from] git2_hooks::HooksError), } /// pub type Result = std::result::Result; impl From> for Error { fn from(error: std::sync::PoisonError) -> Self { Self::Generic(format!("poison error: {error}")) } } impl From> for Error { fn from(error: crossbeam_channel::SendError) -> Self { Self::Generic(format!("send error: {error}")) } }