1use std::io;
2
3use thiserror::Error;
4
5use ecksport_core::frame::FrameType;
6
7use crate::handshake::HandshakeError;
8
9#[derive(Debug, Error)]
10pub enum Error {
11 #[error("unexpected frame {0:?}")]
12 UnexpectedFrame(FrameType),
13
14 #[error("remote sent frame for unknown channel {0}")]
15 RecvOnUnkChan(u32),
16
17 #[error("remote sent frame for channel {0} they closed")]
18 RecvOnClosedChan(u32),
19
20 #[error("tried to send frame on unknown channel {0}")]
21 SendOnUnkChan(u32),
22
23 #[error("tried to send message on closed chan {0}")]
24 SendOnClosedChan(u32),
25
26 #[error("connection timeout")]
27 ConnectionTimeout,
28
29 #[error("connection worker exited")]
30 ConnWorkerExit,
31
32 #[error("connection event receiver channel exited")]
33 ConnRecvDropped,
34
35 #[error("handshake: {0}")]
36 Handshake(HandshakeError),
37
38 #[error("connection: {0}")]
39 Conn(#[from] ecksport_core::errors::ConnError),
40
41 #[error("io: {0}")]
42 IoKind(io::ErrorKind),
43
44 #[error("io: {0}")]
45 Io(#[from] io::Error),
46}
47
48impl From<HandshakeError> for Error {
49 fn from(value: HandshakeError) -> Self {
50 match value {
51 HandshakeError::Io(e) => Self::from(e),
52 HandshakeError::Conn(e) => Self::from(e),
53 e => Self::Handshake(e),
54 }
55 }
56}