Skip to main content

ostrya_server/
error.rs

1//! The error type of the server.
2
3use std::io;
4use std::net::SocketAddr;
5
6/// The result type of the crate.
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// The error of [`bind`](crate::bind) and of
10/// [`ReceiveEndpoint::new`](crate::ReceiveEndpoint::new).
11///
12/// Each error occurs before the server or the host accepts a connection. An
13/// error on one connection ends that connection and no other.
14#[derive(Debug, thiserror::Error)]
15#[non_exhaustive]
16pub enum Error {
17    /// A listen address that cannot be bound, or whose local address cannot
18    /// be read.
19    #[error("bind {addr}: {source}")]
20    Bind {
21        /// The listen address from the options.
22        addr: SocketAddr,
23        /// The I/O error of the bind or of the read of the local address.
24        #[source]
25        source: io::Error,
26    },
27    /// TLS files that give no server configuration.
28    #[error("server tls: {0}")]
29    Tls(String),
30    /// Options that the server refuses. The text states the reason.
31    #[error("invalid serve options: {0}")]
32    Options(String),
33    /// An error of the repository.
34    #[error(transparent)]
35    Repo(#[from] ostrya::Error),
36    /// An I/O error.
37    #[error(transparent)]
38    Io(#[from] io::Error),
39}