1use crate::hash::GitHash;
2
3#[derive(Debug, thiserror::Error)]
4pub enum GitError {
5 #[error("object not found: {0}")]
6 ObjectNotFound(GitHash),
7
8 #[error(
9 "object {0} not found among loose objects; the repository has packfile(s), \
10 which are not yet supported — the object may be packed (this is not a \
11 confirmed absence)"
12 )]
13 PackfileUnsupported(GitHash),
14
15 #[error("invalid hash: {0}")]
16 InvalidHash(String),
17
18 #[error("invalid object: {0}")]
19 InvalidObject(String),
20
21 #[error("hash mismatch: expected {expected}, got {got}")]
22 HashMismatch { expected: GitHash, got: GitHash },
23
24 #[error("ref not found: {0}")]
25 RefNotFound(String),
26
27 #[error("deflate-bomb guard triggered: decompressed size exceeds limit")]
28 DeflateBomb,
29
30 #[error("packfile/index read out of bounds")]
31 OutOfBounds,
32
33 #[error("I/O error: {0}")]
34 Io(#[from] std::io::Error),
35}
36
37pub type Result<T> = std::result::Result<T, GitError>;