hopr_transport_session/
errors.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum TransportSessionError {
6 #[error("connection timed out")]
7 Timeout,
8
9 #[error("incorrect data size")]
10 PayloadSize,
11
12 #[error("invalid peer id")]
13 PeerId,
14
15 #[error("impossible transport path")]
16 Path,
17
18 #[error("no surb available for sending reply data")]
19 OutOfSurbs,
20
21 #[error("unparseable session id")]
22 InvalidSessionId,
23
24 #[error("the other party rejected session initiation with error: {0}")]
25 Rejected(hopr_protocol_start::StartErrorReason),
26
27 #[error("received data for an unregistered session")]
28 UnknownData,
29
30 #[error("packet sending error: {0}")]
31 PacketSendingError(String),
32
33 #[error(transparent)]
34 StartProtocolError(#[from] hopr_protocol_start::errors::StartProtocolError),
35
36 #[error(transparent)]
37 SessionProtocolError(#[from] hopr_protocol_session::errors::SessionError),
38
39 #[error(transparent)]
40 Manager(#[from] SessionManagerError),
41
42 #[error(transparent)]
43 Network(#[from] hopr_network_types::errors::NetworkTypeError),
44
45 #[error("session is closed")]
46 Closed,
47}
48
49impl From<TransportSessionError> for std::io::Error {
50 fn from(error: TransportSessionError) -> Self {
51 std::io::Error::other(error)
52 }
53}
54
55#[derive(Error, Debug)]
56pub enum SessionManagerError {
57 #[error("manager is not started")]
58 NotStarted,
59 #[error("manager is already started")]
60 AlreadyStarted,
61 #[error("all challenge slots are occupied")]
62 NoChallengeSlots,
63 #[error("session with the given id does not exist")]
64 NonExistingSession,
65 #[error("number of sessions exceeds the maximum allowed")]
66 TooManySessions,
67 #[error("loopback sessions are not allowed")]
68 Loopback,
69 #[error("non-specific session manager error: {0}")]
70 Other(String),
71}
72
73pub type Result<T> = std::result::Result<T, TransportSessionError>;