1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum GitCryptError {
5 #[error("Git error: {0}")]
6 Git(#[from] git2::Error),
7
8 #[error("I/O error: {0}")]
9 Io(#[from] std::io::Error),
10
11 #[error("Cryptography error: {0}")]
12 Crypto(String),
13
14 #[error("GPG error: {0}")]
15 Gpg(String),
16
17 #[error("Repository not initialized. Run 'git-crypt init' first")]
18 NotInitialized,
19
20 #[error("Repository already initialized")]
21 AlreadyInitialized,
22
23 #[error("Key not found: {0}")]
24 KeyNotFound(String),
25
26 #[error("Invalid key format")]
27 InvalidKeyFormat,
28
29 #[error("Not in a git repository")]
30 NotInGitRepo,
31
32 #[error("{0}")]
33 Other(String),
34}
35
36pub type Result<T> = std::result::Result<T, GitCryptError>;