1#[derive(Debug)]
5pub enum GitError {
6 NotARepository,
8 GitNotInstalled,
10 CommandFailed {
12 command: String,
14 stderr: String,
16 },
17 ParseError {
19 message: String,
21 },
22}
23
24impl core::fmt::Display for GitError {
25 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26 match self {
27 Self::NotARepository => write!(f, "not a git repository"),
28 Self::GitNotInstalled => write!(f, "git executable not found"),
29 Self::CommandFailed { command, stderr } => {
30 write!(f, "`{command}` failed: {stderr}")
31 }
32 Self::ParseError { message } => write!(f, "porcelain parse error: {message}"),
33 }
34 }
35}
36
37impl core::error::Error for GitError {}