use crate::{ban_manager, session::SendInformation};
use futures::channel::mpsc::SendError;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("Banned connection attempted to connect: {0}")]
ConnectionBanned(ban_manager::Key),
#[error("Session IDs Exhausted")]
SessionIDsExhausted,
#[error("Peer reset connection")]
PeerResetConnection,
#[error(transparent)]
Sender(#[from] tokio::sync::mpsc::error::SendError<SendInformation>),
#[error(transparent)]
Json(#[from] serde_json::error::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
MesssageSend(#[from] SendError),
#[error(transparent)]
AddrParseError(#[from] std::net::AddrParseError),
#[cfg(feature = "api")]
#[error(transparent)]
API(#[from] crate::api::Error),
#[error("Stratum User not authorized")]
NotAuthorized,
#[error("Stratum Stream Closed. Reasion: {0}")]
StreamClosed(String),
#[error("Connection used wrong port in proxy protoocl")]
StreamWrongPort,
#[error("Method does not exist")]
MethodDoesntExist,
#[error("Can't break ExMessage header - Not complete")]
BrokenExHeader,
}