Expand description
Error types for git-spawn.
All commands return Result<T, Error>. The Error type is
non-exhaustive in spirit: callers should match the variants they care
about and fall through to a generic arm.
use git_spawn::{Error, GitCommand, Repository};
let repo = Repository::open("/path/to/repo")?;
match repo.log().max_count(10).execute().await {
Ok(out) => println!("{}", out.stdout),
Err(Error::GitNotFound) => eprintln!("install git first"),
Err(Error::CommandFailed { stderr, exit_code, .. }) => {
eprintln!("git failed (exit {exit_code}):\n{stderr}")
}
Err(Error::Timeout { timeout_seconds }) => {
eprintln!("git didn't respond within {timeout_seconds}s")
}
Err(e) => eprintln!("unexpected: {e}"),
}§When each variant occurs
Error::GitNotFound— the OS reported file not found while spawning. Install git or checkPATH.Error::CommandFailed— git exited non-zero. Readstderrfor the user-facing message; keepstdoutfor anything git wrote to the fast-path.Error::Timeout— the process exceeded the duration passed towith_timeout.Error::Io— OS-level failure unrelated to exit status (e.g. cwd doesn’t exist, pipe error while reading output).Error::InvalidConfig— a builder was missing a required field (for exampleMvCommandwith no source).Error::NotARepository—Repository::openwas called on a path that has no.git.Error::ParseError— a parser incrate::parsecould not decode the captured output.Error::UnsupportedVersion— reserved for future version gating; not currently emitted.Error::Custom— catch-all for cases the library cannot classify.
Enums§
- Error
- Main error type for all git-spawn operations.
Type Aliases§
- Result
- Result type for git-spawn operations.