webparse/url/error.rs
1// Copyright 2022 - 2023 Wenmeng See the COPYRIGHT
2// file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8//
9// Author: tickbh
10// -----
11// Created Date: 2023/08/21 06:16:49
12
13use std::fmt;
14
15
16
17#[derive(Debug)]
18pub enum UrlError {
19 UrlInvalid,
20 UrlCodeInvalid,
21}
22
23
24impl UrlError {
25 #[inline]
26 pub fn description_str(&self) -> &'static str {
27 match self {
28 UrlError::UrlInvalid => "invalid Url",
29 UrlError::UrlCodeInvalid => "invalid Url Code",
30 }
31 }
32}
33
34
35impl fmt::Display for UrlError {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 f.write_str(self.description_str())
38 }
39}