reception/listener/error.rs
1use std::net::{AddrParseError, SocketAddr};
2
3use thiserror::Error;
4
5/// Errors that can be raised by [`Listener`](`crate::Listener`).
6#[derive(Error, Debug)]
7pub enum ListenerError {
8 /// Listener's configuration is invalid.
9 #[error("invalid listener socket configuration")]
10 SocketConfiguration(#[source] AddrParseError),
11
12 /// Failed to bind listener to the configured socket.
13 #[error("failed to bind listener to {addr}")]
14 BindingError {
15 /// Socket address it tried to bind to.
16 addr: SocketAddr,
17
18 /// Original error.
19 #[source]
20 source: std::io::Error,
21 },
22
23 /// Failed to accept a new connection.
24 ///
25 /// The listener is considered to be broken. It stops listening on the configured socket and unbinds itself.
26 #[error("failed to accept a new connection")]
27 AcceptConnection(#[source] std::io::Error),
28}