#[non_exhaustive]pub enum Error {
Show 20 variants
Repository(RepositoryError),
Object(ObjectError),
Index(IndexError),
Ref(RefError),
Revision(RevisionError),
Config(ConfigError),
Worktree(WorktreeError),
Diff(DiffError),
Commit(CommitError),
Merge(MergeError),
History(HistoryError),
Stash(StashError),
Branch(BranchError),
Tag(TagError),
Notes(NotesError),
Remote(RemoteError),
Hook(HookError),
Io(Error),
LockHeld(LockHeldError),
Cancelled,
}Expand description
The top-level error type for all grit-lib operations.
Every variant is one functional area (plus the cross-cutting Self::Io,
Self::LockHeld and Self::Cancelled). Each area enum carries that area’s specific
failures with structured fields; match on the area first, then on its enum.
§Examples
use grit_lib::error::{Error, ObjectError};
let err = Error::Object(ObjectError::NotFound { name: "1234abcd".into() });
assert_eq!(err.area(), "object");
assert_eq!(err.kind_name(), "object_not_found");
assert!(matches!(err, Error::Object(ObjectError::NotFound { .. })));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Repository(RepositoryError)
Repository discovery, layout, format, and maintenance-lock failures.
Object(ObjectError)
Object database, pack, commit-graph, multi-pack-index, and promisor failures.
Index(IndexError)
Index read, write, extension, or write-tree failure.
Ref(RefError)
Reference, reflog, ref store, and HEAD state failures.
Revision(RevisionError)
Revision lookup, parsing, and walk failures.
Config(ConfigError)
Configuration parse, validation, and write failures.
Worktree(WorktreeError)
Work tree, path, pathspec, checkout, filter, submodule, and linked worktree failures.
Diff(DiffError)
Patch application, hunk selection, and blame failures.
Commit(CommitError)
Commit, identity, signing, and patch-scoped commit failures.
Merge(MergeError)
Merge, cherry-pick, revert, and in-progress operation failures.
History(HistoryError)
History rewrite (grit history, rebase) failures.
Stash(StashError)
Stash push, apply, and stack failures.
Branch(BranchError)
Branch create, delete, lookup, and upstream configuration failures.
Tag(TagError)
Tag create, delete, and verification failures.
Notes(NotesError)
Notes ref, notes tree, and notes merge failures.
Remote(RemoteError)
Remote transport, fetch, push, and clone failures.
Hook(HookError)
A Git hook subprocess failed or could not be started.
Io(Error)
An I/O error from the underlying filesystem.
LockHeld(LockHeldError)
A lock file (for example .git/index.lock or refs/heads/main.lock) already exists, so
another process is updating the same file or a crashed one left the lock behind.
Operations that return this before changing anything leave the repository untouched.
The lock file belongs to whoever created it and is never removed. Retry once the other
process finishes, or delete the lock path when no process owns it (a holder with
running: false means the lock is stale).
Cancelled
A long-running library operation stopped at a cancellation checkpoint.
Use Error::is_cancelled to test for it, including cancellations recorded inside
area errors.
Implementations§
Source§impl Error
impl Error
Sourcepub fn kind_name(&self) -> &'static str
pub fn kind_name(&self) -> &'static str
Stable snake_case name of this error’s specific failure (for example
"not_a_repository"), for scripts and serialized output that must branch on the
failure kind.
The names are the leaf failure names and change only when a failure is renamed. Match on the error value itself in Rust code.
§Examples
use grit_lib::error::Error;
use grit_lib::porcelain::CommitError;
assert_eq!(
Error::Commit(CommitError::NothingToCommit).kind_name(),
"nothing_to_commit"
);
assert_eq!(Error::Cancelled.kind_name(), "cancelled");Sourcepub fn area(&self) -> &'static str
pub fn area(&self) -> &'static str
Functional area of this error: the snake_case name of its umbrella variant
("repository", "object", "index", "ref", …).
§Examples
use grit_lib::error::Error;
assert_eq!(Error::Cancelled.area(), "cancelled");Sourcepub fn dirty_worktree(
operation: WorktreeOperation,
affected_paths: Vec<String>,
) -> Self
pub fn dirty_worktree( operation: WorktreeOperation, affected_paths: Vec<String>, ) -> Self
Build WorktreeError::DirtyWorktree,
sorting and deduplicating paths.
Sourcepub fn would_overwrite(
reason: OverwriteReason,
affected_paths: Vec<String>,
) -> Self
pub fn would_overwrite( reason: OverwriteReason, affected_paths: Vec<String>, ) -> Self
Build WorktreeError::WouldOverwrite
for switch and similar tree transitions.
Sourcepub fn remote_unreadable(
url: impl Into<String>,
reason: RemoteUnreadableReason,
) -> Self
pub fn remote_unreadable( url: impl Into<String>, reason: RemoteUnreadableReason, ) -> Self
Build crate::remote::RemoteError::Unreadable for url.
Sourcepub fn is_remote_unreadable(&self) -> bool
pub fn is_remote_unreadable(&self) -> bool
Whether this is an unreadable remote failure (see crate::remote::RemoteError::is_remote_unreadable).
Sourcepub fn lock_held(&self) -> Option<&LockHeldError>
pub fn lock_held(&self) -> Option<&LockHeldError>
When this is Error::LockHeld, returns the structured lock failure.
Sourcepub fn path_io(&self) -> Option<PathIoError>
pub fn path_io(&self) -> Option<PathIoError>
When this is a worktree or git-dir path I/O failure, returns the shared leaf shape.
Sourcepub fn is_worktree_file_in_use(&self) -> bool
pub fn is_worktree_file_in_use(&self) -> bool
Whether this is a work-tree path I/O failure caused by another process holding the
file open (a Windows sharing or lock violation, EBUSY, or would-block), so retrying
after closing that program can succeed.
Sourcepub fn is_git_dir_file_in_use(&self) -> bool
pub fn is_git_dir_file_in_use(&self) -> bool
Whether this is RepositoryError::git_dir_path_io caused by another process holding a git-dir file
open (Windows sharing or access-denied during replace, EBUSY, …).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether this is Error::Cancelled or an area failure recording a cancellation.
Sourcepub fn is_damaged_object(&self) -> bool
pub fn is_damaged_object(&self) -> bool
Whether an object read failed because a stored copy is damaged (zlib/header/truncation), so composite stores may consult the next backend.
Sourcepub fn invalid_path_component(
path: impl Into<String>,
reason: PathComponentError,
) -> Self
pub fn invalid_path_component( path: impl Into<String>, reason: PathComponentError, ) -> Self
Sourcepub fn wants_fatal_prefix(&self) -> bool
pub fn wants_fatal_prefix(&self) -> bool
When set, the CLI should prefix stderr with fatal: for Git-compatible commands.
Sourcepub fn git_stderr_message(&self) -> String
pub fn git_stderr_message(&self) -> String
Format for Git-style stderr (adds fatal: / error: when appropriate).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<&Error> for ErrorSummary
impl From<&Error> for ErrorSummary
Source§impl From<ApplyError> for Error
impl From<ApplyError> for Error
Source§fn from(err: ApplyError) -> Self
fn from(err: ApplyError) -> Self
Source§impl From<AuthorArgError> for Error
impl From<AuthorArgError> for Error
Source§fn from(err: AuthorArgError) -> Self
fn from(err: AuthorArgError) -> Self
Source§impl From<BitmapError> for Error
impl From<BitmapError> for Error
Source§fn from(err: BitmapError) -> Self
fn from(err: BitmapError) -> Self
Source§impl From<BitmapWalkError> for Error
impl From<BitmapWalkError> for Error
Source§fn from(err: BitmapWalkError) -> Self
fn from(err: BitmapWalkError) -> Self
Source§impl From<BitmapWalkUnsupported> for Error
impl From<BitmapWalkUnsupported> for Error
Source§fn from(err: BitmapWalkUnsupported) -> Self
fn from(err: BitmapWalkUnsupported) -> Self
Source§impl From<BranchError> for Error
impl From<BranchError> for Error
Source§fn from(source: BranchError) -> Self
fn from(source: BranchError) -> Self
Source§impl From<BundleError> for Error
impl From<BundleError> for Error
Source§fn from(err: BundleError) -> Self
fn from(err: BundleError) -> Self
Source§impl From<ChangeIdError> for Error
impl From<ChangeIdError> for Error
Source§fn from(err: ChangeIdError) -> Self
fn from(err: ChangeIdError) -> Self
Source§impl From<CheckoutError> for Error
impl From<CheckoutError> for Error
Source§fn from(err: CheckoutError) -> Self
fn from(err: CheckoutError) -> Self
Source§impl From<CloneError> for Error
impl From<CloneError> for Error
Source§fn from(err: CloneError) -> Self
fn from(err: CloneError) -> Self
Source§impl From<CommitError> for Error
impl From<CommitError> for Error
Source§fn from(err: CommitError) -> Self
fn from(err: CommitError) -> Self
Source§impl From<CommitIdentityError> for Error
impl From<CommitIdentityError> for Error
Source§fn from(err: CommitIdentityError) -> Self
fn from(err: CommitIdentityError) -> Self
Source§impl From<ConfigError> for Error
impl From<ConfigError> for Error
Source§fn from(source: ConfigError) -> Self
fn from(source: ConfigError) -> Self
Source§impl From<Error> for ErrorSummary
impl From<Error> for ErrorSummary
Source§impl From<Error> for UnpackError
impl From<Error> for UnpackError
Source§impl From<FetchRefspecError> for Error
impl From<FetchRefspecError> for Error
Source§fn from(e: FetchRefspecError) -> Self
fn from(e: FetchRefspecError) -> Self
Source§impl From<FilterError> for Error
impl From<FilterError> for Error
Source§fn from(err: FilterError) -> Self
fn from(err: FilterError) -> Self
Source§impl From<FuncnamePatternError> for Error
impl From<FuncnamePatternError> for Error
Source§fn from(err: FuncnamePatternError) -> Self
fn from(err: FuncnamePatternError) -> Self
Source§impl From<HistoryError> for Error
impl From<HistoryError> for Error
Source§fn from(err: HistoryError) -> Self
fn from(err: HistoryError) -> Self
Source§impl From<HunkSelectError> for Error
impl From<HunkSelectError> for Error
Source§fn from(err: HunkSelectError) -> Self
fn from(err: HunkSelectError) -> Self
Source§impl From<IdentityError> for Error
impl From<IdentityError> for Error
Source§fn from(err: IdentityError) -> Self
fn from(err: IdentityError) -> Self
Source§impl From<IndexError> for Error
impl From<IndexError> for Error
Source§fn from(err: IndexError) -> Self
fn from(err: IndexError) -> Self
Source§impl From<LinkedWorktreeError> for Error
impl From<LinkedWorktreeError> for Error
Source§fn from(value: LinkedWorktreeError) -> Self
fn from(value: LinkedWorktreeError) -> Self
Source§impl From<LockError> for Error
impl From<LockError> for Error
Source§fn from(err: LockError) -> Self
fn from(err: LockError) -> Self
LockError::Held becomes Error::LockHeld with the
recorded LockHolder, and I/O failures become Error::Io.