Skip to main content

better_url/errors/host/
mod.rs

1//! Host stuff.
2
3use thiserror::Error;
4
5use crate::prelude::*;
6
7mod domain; pub use domain::*;
8
9mod either          ; pub use either          ::*;
10mod file            ; pub use file            ::*;
11mod special_not_file; pub use special_not_file::*;
12mod non_special     ; pub use non_special     ::*;
13
14/// Returned when failing to parse an IPv4 host.
15#[derive(Debug, Error)]
16#[error("Failed to parse an IPv4 host.")]
17pub struct InvalidIpv4Host;
18
19/// Returned when failing to parse an IPv6 host.
20#[derive(Debug, Error)]
21#[error("Failed to parse an IPv6 host.")]
22pub struct InvalidIpv6Host;
23
24/// Returned when failing to parse an opaque host.
25#[derive(Debug, Error)]
26#[error("Failed to parse an opaque host.")]
27pub struct InvalidOpaqueHost;
28
29/// Returned when failing to parse an empty host.
30#[derive(Debug, Error)]
31#[error("Failed to parse an empty host.")]
32pub struct InvalidEmptyHost;
33
34/// Returned when failing to get a host.
35#[derive(Debug, Error)]
36#[error("Failed to get a host.")]
37pub struct NoHost;
38
39/// Returned when failing to get a domain.
40#[derive(Debug, Error)]
41#[error("Failed to get a domain.")]
42pub struct NoDomain;
43
44/// Returned when attempting to set a URL that can't have a host to have a host.
45#[derive(Debug, Error)]
46#[error("Attempted to set a URL that can't have a host to have a host.")]
47pub struct CantHaveHost;
48
49/// Returned when failing to set a host.
50#[derive(Debug, Error)]
51pub enum SetHostError {
52    /** [`InvalidHost`].    */ #[error(transparent)] InvalidHost   (#[from] InvalidHost   ),
53    /** [`SetDomainError`]. */ #[error(transparent)] SetDomainError(#[from] SetDomainError),
54    /** [`NoDomain`]        */ #[error(transparent)] NoDomain      (#[from] NoDomain      ),
55    /** [`CantBeNone`].     */ #[error(transparent)] CantBeNone    (#[from] CantBeNone    ),
56    /** [`CantBeEmpty`].    */ #[error(transparent)] CantBeEmpty   (#[from] CantBeEmpty   ),
57    /** [`CantHaveHost`].   */ #[error(transparent)] CantHaveHost  (#[from] CantHaveHost  ),
58    /** [`TooLong`].        */ #[error(transparent)] TooLong       (#[from] TooLong       ),
59}