1use std::{io, time::Duration};
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum ClientError {
7 #[error("failed to resolve server address {addr:?}")]
8 Resolve { addr: String },
9 #[error("socket error: {0}")]
10 Socket(#[from] io::Error),
11 #[error("socket option error while trying to {operation} for {remote}: {source}")]
12 SocketOption {
13 operation: &'static str,
14 remote: std::net::SocketAddr,
15 source: io::Error,
16 },
17 #[error("failed to restore configured socket read timeout after open negotiation: {source}")]
18 ReadTimeoutRestore { source: io::Error },
19 #[error("protocol error: {0}")]
20 Protocol(#[from] irtt_proto::ProtoError),
21 #[error("all open requests timed out")]
22 OpenTimeout,
23 #[error("open timeout {timeout:?} is below the minimum {minimum:?}")]
24 OpenTimeoutTooSmall {
25 timeout: Duration,
26 minimum: Duration,
27 },
28 #[error("open_timeouts must not be empty")]
29 NoOpenTimeouts,
30 #[error("server rejected the open request")]
31 ServerRejected,
32 #[error("unexpected no-test open reply")]
33 UnexpectedNoTestReply,
34 #[error("no-test reply included a non-zero connection token: {token}")]
35 NonZeroNoTestToken { token: u64 },
36 #[error("protocol version mismatch: requested {requested}, received {received}")]
37 ProtocolVersionMismatch { requested: i64, received: i64 },
38 #[error("server returned a zero connection token")]
39 ZeroToken,
40 #[error("strict negotiation rejected changed params: {reason}")]
41 NegotiationRejected { reason: String },
42 #[error("client is not open")]
43 NotOpen,
44 #[error("client session is already open")]
45 AlreadyOpen,
46 #[error("client session is already completed")]
47 AlreadyCompleted,
48 #[error("client session is already closed")]
49 AlreadyClosed,
50 #[error("duration is too large to encode as nanoseconds")]
51 DurationOverflow,
52 #[error("counter {counter} overflowed")]
53 CounterOverflow { counter: &'static str },
54 #[error("pending probe limit exceeded ({limit})")]
55 PendingLimitExceeded { limit: usize },
56 #[error("invalid configuration: {reason}")]
57 InvalidConfig { reason: String },
58 #[error("managed client worker thread panicked")]
59 WorkerPanicked,
60}
61
62#[derive(Debug, Error, Clone, Copy, PartialEq, Eq)]
63pub enum EventSubscriptionError {
64 #[error("event subscription is disconnected")]
65 Disconnected,
66}