Skip to main content

normalize_url/
error.rs

1use std::error::Error;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Debug)]
5pub enum NormalizeError {
6    UrlParseError,
7    InternalError,
8    UrlEncodeError,
9    RegexParseError(String),
10}
11
12impl Display for NormalizeError {
13    fn fmt(&self, f: &mut Formatter) -> Result {
14        match self {
15            NormalizeError::UrlParseError => write!(f, "Url parse error."),
16            NormalizeError::InternalError => write!(f, "Internal error."),
17            NormalizeError::UrlEncodeError => write!(f, "Url encode error."),
18            NormalizeError::RegexParseError(regex) => write!(f, "Regex parse error:{}", regex),
19        }
20    }
21}
22
23impl Error for NormalizeError {
24    fn description(&self) -> &str {
25        "Url canonicalization failed:"
26    }
27}