Skip to main content

typhoon/socket/
error.rs

1use cfg_if::cfg_if;
2use thiserror::Error;
3
4use crate::flow::FlowControllerError;
5cfg_if! {
6    if #[cfg(feature = "client")] {
7        use std::net::SocketAddr;
8        use crate::certificate::CertificateError;
9    }
10}
11use crate::session::SessionControllerError;
12use crate::utils::socket::SocketError;
13
14#[cfg(feature = "client")]
15#[derive(Error, Debug)]
16pub enum ClientSocketError {
17    #[error("flow controller error: {}", .0.to_string())]
18    FlowError(#[source] FlowControllerError),
19
20    #[error("session controller error: {}", .0.to_string())]
21    SessionError(#[source] SessionControllerError),
22
23    #[error("socket error: {}", .0.to_string())]
24    SocketError(#[source] SocketError),
25
26    #[error("certificate error: {}", .0.to_string())]
27    CertificateError(#[source] CertificateError),
28
29    #[error("address {0} is not present in the certificate")]
30    AddressNotInCertificate(SocketAddr),
31
32    #[error("receive channel closed")]
33    ChannelClosed,
34
35    #[error("unsupported runtime: {0}")]
36    UnsupportedRuntime(&'static str),
37}
38
39#[cfg(feature = "server")]
40#[derive(Error, Debug)]
41pub enum ServerSocketError {
42    #[error("flow controller error: {}", .0.to_string())]
43    FlowError(#[source] FlowControllerError),
44
45    #[error("session controller error: {}", .0.to_string())]
46    SessionError(#[source] SessionControllerError),
47
48    #[error("socket error: {}", .0.to_string())]
49    SocketError(#[source] SocketError),
50
51    #[error("no flow configurations provided")]
52    NoFlows,
53
54    #[error("receive channel closed")]
55    ChannelClosed,
56
57    #[error("listener stopped")]
58    ListenerStopped,
59
60    #[error("unsupported runtime: {0}")]
61    UnsupportedRuntime(&'static str),
62}