Skip to main content

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    /// I/O operation failed
14    #[error("I/O error: {0}")]
15    Io(String),
16
17    /// Invalid operation for current peer state
18    #[error("Invalid operation: {0}")]
19    InvalidOperation(String),
20}
21
22impl From<io::Error> for PeerError {
23    fn from(error: io::Error) -> Self {
24        PeerError::Io(error.to_string())
25    }
26}
27
28/// Result type for peer operations.
29pub type PeerResult<T> = Result<T, PeerError>;