hopr_protocol_session/
errors.rs1use hopr_primitive_types::prelude::GeneralError;
2use thiserror::Error;
3
4use crate::protocol::FrameId;
5
6#[derive(Error, Debug)]
7pub enum SessionError {
8 #[error("error while processing frame or segment: {0}")]
9 ProcessingError(String),
10
11 #[error("socket is in invalid state: {0}")]
12 InvalidState(String),
13
14 #[error("socket state is not running")]
15 StateNotRunning,
16
17 #[error("failed to parse session message")]
18 ParseError,
19
20 #[error("invalid protocol version")]
21 WrongVersion,
22
23 #[error("message has an incorrect length")]
24 IncorrectMessageLength,
25
26 #[error("the message has an unknown tag")]
27 UnknownMessageTag,
28
29 #[error("session is closed")]
30 SessionClosed,
31
32 #[error("attempt to insert invalid frame id")]
33 InvalidFrameId,
34
35 #[error("input data exceeds the maximum allowed size of the message")]
36 DataTooLong,
37
38 #[error("cannot reassemble frame {0}, because it is not complete")]
39 IncompleteFrame(FrameId),
40
41 #[error("there are too many incomplete frames in the reassembler")]
42 TooManyIncompleteFrames,
43
44 #[error("segment could not be parsed correctly")]
45 InvalidSegment,
46
47 #[error("frame {0} has expired or has been discarded")]
48 FrameDiscarded(FrameId),
49
50 #[error(transparent)]
51 IoError(#[from] std::io::Error),
52
53 #[error(transparent)]
54 GeneralError(#[from] GeneralError),
55}
56
57pub type Result<T> = std::result::Result<T, SessionError>;