1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum VcsError {
6 #[error("git error: {0}")]
9 Git(Box<gix::discover::Error>),
10
11 #[error("object not found: {0}")]
13 ObjectNotFound(String),
14
15 #[error("reference not found: {0}")]
17 ReferenceNotFound(String),
18
19 #[error("git command failed to start ({context}): {source}")]
21 GitCommand {
22 context: String,
23 #[source]
24 source: std::io::Error,
25 },
26
27 #[error("git command failed: {stderr}")]
29 GitCommandFailed { stderr: String },
30
31 #[error("utf-8 conversion failed ({context}): {source}")]
33 Utf8 {
34 context: String,
35 #[source]
36 source: std::string::FromUtf8Error,
37 },
38
39 #[error("operation requires a working tree, but this is a bare repository: {0}")]
42 BareRepo(String),
43
44 #[error("index operation failed: {0}")]
46 Index(String),
47
48 #[error("stash operation failed: {0}")]
50 Stash(String),
51
52 #[error("remote operation failed: {0}")]
54 Remote(String),
55
56 #[error("bisect operation failed: {0}")]
58 Bisect(String),
59
60 #[error("submodule operation failed: {0}")]
62 Submodule(String),
63
64 #[error("notes operation failed: {0}")]
66 Note(String),
67
68 #[error("status parse error: {0}")]
70 StatusParse(String),
71}
72
73impl From<gix::discover::Error> for VcsError {
74 fn from(e: gix::discover::Error) -> Self {
75 VcsError::Git(Box::new(e))
76 }
77}
78
79pub type Result<T, E = VcsError> = std::result::Result<T, E>;