use crate::Error;
use std::fmt::{Display, Formatter};
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
pub struct InvalidUrlError {
error: Error,
url: String,
}
impl InvalidUrlError {
pub(crate) const fn new(error: Error, url: String) -> Self {
Self { error, url }
}
}
impl InvalidUrlError {
#[must_use]
pub const fn error(&self) -> Error {
self.error
}
#[must_use]
pub fn url(&self) -> &str {
self.url.as_str()
}
}
impl InvalidUrlError {
#[must_use]
pub fn into_url(self) -> String {
self.url
}
}
impl From<InvalidUrlError> for Error {
fn from(error: InvalidUrlError) -> Self {
error.error
}
}
impl Display for InvalidUrlError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.pad(self.error.message())
}
}
impl std::error::Error for InvalidUrlError {}