#[derive(Debug)]
pub enum GitError {
NotARepository,
GitNotInstalled,
CommandFailed {
command: String,
stderr: String,
},
ParseError {
message: String,
},
}
impl core::fmt::Display for GitError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::NotARepository => write!(f, "not a git repository"),
Self::GitNotInstalled => write!(f, "git executable not found"),
Self::CommandFailed { command, stderr } => {
write!(f, "`{command}` failed: {stderr}")
}
Self::ParseError { message } => write!(f, "porcelain parse error: {message}"),
}
}
}
impl core::error::Error for GitError {}