moonpool_transport/peer/
error.rs

1//! Error types for peer operations.
2
3use std::io;
4use thiserror::Error;
5
6/// Errors that can occur during peer operations.
7#[derive(Error, Debug, Clone)]
8pub enum PeerError {
9    /// Connection failed and could not be established
10    #[error("Connection to peer failed")]
11    ConnectionFailed,
12
13    /// Connection was lost during operation
14    #[error("Connection lost during operation")]
15    ConnectionLost,
16
17    /// Message queue is full
18    #[error("Message queue is full, cannot queue more messages")]
19    QueueFull,
20
21    /// Peer is disconnected and cannot perform operation
22    #[error("Peer is disconnected")]
23    Disconnected,
24
25    /// Connection timeout occurred
26    #[error("Connection timeout")]
27    Timeout,
28
29    /// I/O operation failed
30    #[error("I/O error: {0}")]
31    Io(String),
32
33    /// Invalid operation for current peer state
34    #[error("Invalid operation: {0}")]
35    InvalidOperation(String),
36
37    /// Receiver has been taken via take_receiver()
38    #[error("Receiver has been taken")]
39    ReceiverTaken,
40}
41
42impl From<io::Error> for PeerError {
43    fn from(error: io::Error) -> Self {
44        PeerError::Io(error.to_string())
45    }
46}
47
48/// Result type for peer operations.
49pub type PeerResult<T> = Result<T, PeerError>;