use thiserror::Error;
use crate::{connection_manager::ConnectionManagerError, peer_manager::PeerManagerError, PeerConnectionError};
#[derive(Debug, Error)]
pub enum ConnectivityError {
#[error("Cannot send request because ConnectivityActor disconnected")]
ActorDisconnected,
#[error("Internal actor response was unexpectedly cancelled")]
ActorResponseCancelled,
#[error("PeerManagerError: {0}")]
PeerManagerError(#[from] PeerManagerError),
#[error("Peer connection error: {0}")]
PeerConnectionError(#[from] PeerConnectionError),
#[error("ConnectionFailed: {0}")]
ConnectionFailed(ConnectionManagerError),
#[error("Connectivity event stream closed unexpectedly")]
ConnectivityEventStreamClosed,
#[error("Timeout while waiting for node to come online ({0} peer(s) connected)")]
OnlineWaitTimeout(usize),
#[error("Pending dial was cancelled")]
DialCancelled,
#[error("Client cancelled: '{0}'")]
ClientCancelled(String),
}
impl From<ConnectionManagerError> for ConnectivityError {
fn from(err: ConnectionManagerError) -> Self {
match err {
ConnectionManagerError::DialCancelled => Self::DialCancelled,
err => Self::ConnectionFailed(err),
}
}
}