web_url/error/
invalid_url_error.rs1use crate::Error;
2use std::fmt::{Display, Formatter};
3
4#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
8pub struct InvalidUrlError {
9 error: Error,
10 url: String,
11}
12
13impl InvalidUrlError {
14 pub(crate) const fn new(error: Error, url: String) -> Self {
18 Self { error, url }
19 }
20}
21
22impl InvalidUrlError {
23 #[must_use]
27 pub const fn error(&self) -> Error {
28 self.error
29 }
30
31 #[must_use]
33 pub fn url(&self) -> &str {
34 self.url.as_str()
35 }
36}
37
38impl InvalidUrlError {
39 #[must_use]
43 pub fn into_url(self) -> String {
44 self.url
45 }
46}
47
48impl From<InvalidUrlError> for Error {
49 fn from(error: InvalidUrlError) -> Self {
50 error.error
51 }
52}
53
54impl Display for InvalidUrlError {
55 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
56 f.pad(self.error.message())
57 }
58}
59
60impl std::error::Error for InvalidUrlError {}