Skip to main content

git_side/
error.rs

1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("not in a git repository")]
6    NotInGitRepo,
7
8    #[error("no commits in repository (cannot determine project identity)")]
9    NoCommits,
10
11    #[error("git command failed: {0}")]
12    GitCommandFailed(String),
13
14    #[error("path not found: {}", .0.display())]
15    PathNotFound(PathBuf),
16
17    #[error("path already tracked: {}", .0.display())]
18    PathAlreadyTracked(PathBuf),
19
20    #[error("path not tracked: {}", .0.display())]
21    PathNotTracked(PathBuf),
22
23    #[error("nothing to commit")]
24    NothingToCommit,
25
26    #[error("no tracked paths configured")]
27    NoTrackedPaths,
28
29    #[error("hook already installed: {0}")]
30    HookAlreadyInstalled(String),
31
32    #[error("hook not installed: {0}")]
33    HookNotInstalled(String),
34
35    #[error("failed to read {}: {source}", path.display())]
36    ReadFile {
37        path: PathBuf,
38        #[source]
39        source: std::io::Error,
40    },
41
42    #[error("failed to write {}: {source}", path.display())]
43    WriteFile {
44        path: PathBuf,
45        #[source]
46        source: std::io::Error,
47    },
48
49    #[error("failed to create directory {}: {source}", path.display())]
50    CreateDir {
51        path: PathBuf,
52        #[source]
53        source: std::io::Error,
54    },
55
56    #[error("invalid config format in {}", path.display())]
57    InvalidConfig { path: PathBuf },
58}
59
60pub type Result<T> = std::result::Result<T, Error>;