//! Errors for this crate
use nostr_rs_types::Request;
use tokio::sync::mpsc::error::SendError;
use tokio_tungstenite::tungstenite::error::Error as TungsteniteError;

/// Crate errors
#[derive(thiserror::Error, Debug)]
pub enum Error {
    /// Error parsing the Url
    #[error("Url: {0}")]
    Url(#[from] url::ParseError),

    /// WebSocket client error
    #[error("Tungstenite: {0}")]
    Tungstenite(#[from] TungsteniteError),

    /// Internal error using the Sync channels
    #[error("Sync: {0}")]
    Sync(#[from] Box<SendError<Request>>),

    /// The client has no connection to any relayer
    #[error("There is no connection")]
    Disconnected,

    /// The pool was already splitted
    #[error("The pool was already splitted")]
    AlreadySplitted,
}
