use std::fmt;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("{0}")]
Protocol(String),
#[error("{0}")]
Invalid(String),
#[error("an object id is {theirs} but the repository is {ours}")]
ObjectFormat {
ours: &'static str,
theirs: &'static str,
},
#[error("remote error: {0}")]
Remote(String),
#[error("io: {0}")]
Io(#[from] std::io::Error),
}
impl Error {
pub fn protocol(message: impl fmt::Display) -> Self {
Error::Protocol(message.to_string())
}
pub fn invalid(message: impl fmt::Display) -> Self {
Error::Invalid(message.to_string())
}
}
pub type Result<T> = std::result::Result<T, Error>;