#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
InvalidUrl {
source: String,
},
UnsupportedScheme {
scheme: String,
},
Io {
message: String,
},
InvalidStatusLine {
text: String,
},
InvalidHeader {
line: String,
},
InvalidHeaderName {
name: String,
},
}
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
Self::Io {
message: format!("{value}"),
}
}
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::InvalidUrl { source } => write!(f, "invalid url: {source:?}"),
Self::UnsupportedScheme { scheme } => write!(f, "unsupported scheme: {scheme:?}"),
Self::Io { message } => write!(f, "i/o error: {message}"),
Self::InvalidStatusLine { text } => write!(f, "invalid status line: {text:?}"),
Self::InvalidHeader { line } => write!(f, "invalid header line: {line:?}"),
Self::InvalidHeaderName { name } => write!(f, "invalid header name: {name:?}"),
}
}
}
impl std::error::Error for Error {}