pub enum Error {
BadPlatformType(String),
MissingUrl,
BadUrl(url::ParseError),
}
fn fmt_config_error(err: &Error, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &err {
Error::BadPlatformType(str) => write!(f, "Platform must be 'forgejo'. Instead got: {str}"),
Error::MissingUrl => write!(f, "No platform source URL was given."),
Error::BadUrl(_) => write!(f, "Invalid source URL was given."),
}
}
impl std::fmt::Debug for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt_config_error(&self, f)
}
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt_config_error(&self, f)
}
}
impl std::error::Error for Error {}