git_indexer/
error.rs

1//! Error types for the git-indexer crate.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Result type alias using the crate's Error type.
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// Main error type for the git-indexer crate.
10#[derive(Error, Debug)]
11pub enum Error {
12    /// Error during git repository operations.
13    #[error("Git error: {0}")]
14    Git(#[from] GitError),
15
16    /// JSON serialization/deserialization error.
17    #[error("JSON error: {0}")]
18    Json(#[from] serde_json::Error),
19}
20
21/// Errors related to git repository operations.
22#[derive(Error, Debug)]
23pub enum GitError {
24    /// Failed to discover or open a git repository.
25    #[error("Failed to discover git repository at {path}: {message}")]
26    RepositoryNotFound { path: PathBuf, message: String },
27
28    /// Failed to read repository references.
29    #[error("Failed to read references: {0}")]
30    ReferencesError(String),
31
32    /// Failed to read a commit object.
33    #[error("Failed to read commit {commit_id}: {message}")]
34    CommitReadError { commit_id: String, message: String },
35
36    /// Failed to read a tree object.
37    #[error("Failed to read tree: {0}")]
38    TreeReadError(String),
39
40    /// Failed to read a max file size limit.
41    #[error("Failed to read blob {blob_id}: {message}")]
42    BlobReadError { blob_id: String, message: String },
43
44    /// Generic git operation error.
45    #[error("Git operation failed: {0}")]
46    OperationFailed(String),
47}