Skip to main content

Module error

Module error 

Source
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

Enums§

Error
Main error type for all git-spawn operations.

Type Aliases§

Result
Result type for git-spawn operations.