pub enum Error {
UnexpectedResponse,
NetworkFailure,
ResourceNotFound,
}
fn fmt_error(err: &Error, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &err {
Error::UnexpectedResponse => write!(f, "Can't understand the response from the git forge"),
Error::NetworkFailure => write!(f, "Failed to communicate with the git forge"),
Error::ResourceNotFound => write!(f, "The requested resource was not found"),
}
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt_error(&self, f)
}
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt_error(&self, f)
}
}
impl std::error::Error for Error {}