Skip to main content

better_url/errors/
port.rs

1//! Port stuff.
2
3use thiserror::Error;
4
5use crate::prelude::*;
6
7/// Returned when attempting to parse an invalid port.
8#[derive(Debug, Error)]
9#[error("Attempted to parse an invalid port.")]
10pub struct InvalidPort;
11
12/// The error [`BetterUrl::set_port`] returns when it fails.
13#[derive(Debug, Error)]
14pub enum SetPortError {
15    /// [`NoHost`].
16    #[error(transparent)]
17    NoHost(#[from] NoHost),
18    /// Returned when attempting to set the port of an empty host.
19    #[error("Attempted to set the port of an empty host.")]
20    EmptyHost,
21    /// Returned when attempting to set the port of a file URL.
22    #[error("Attempted to set the port of a file URL.")]
23    SchemeIsFile,
24    /// [`InvalidPort`].
25    #[error(transparent)]
26    InvalidPort(#[from] InvalidPort),
27    /// Returned when attempting to set a URL that can't have a port to have a port.
28    #[error("Attempted to set a URL that can't have a port to have a port")]
29    CantHavePort,
30    /// [`TooLong`].
31    #[error(transparent)]
32    TooLong(#[from] TooLong),
33}