use std::sync::PoisonError;
use crate::shared::error::{AsyncChannelError, ConnectionAlreadyClosed, ConnectionSendError};
use super::connection::ConnectionLocalId;
#[derive(thiserror::Error, Debug)]
pub enum ClientSendError {
#[error("Connection is 'disconnected'")]
ConnectionClosed,
#[error("Error when sending data on the connection")]
ConnectionSendError(#[from] ConnectionSendError),
}
#[derive(thiserror::Error, Debug)]
pub enum ClientPayloadSendError {
#[error("There is no default channel")]
NoDefaultChannel,
#[error("Error when sending")]
SendError(#[from] ClientSendError),
}
#[derive(thiserror::Error, Debug)]
#[error("The client connection is closed")]
pub struct ConnectionClosed;
#[derive(thiserror::Error, Debug)]
pub enum ClientConnectionCloseError {
#[error("Connection is already closed")]
ConnectionAlreadyClosed(#[from] ConnectionAlreadyClosed),
#[error("Connection id `{0}` is invalid")]
InvalidConnectionId(ConnectionLocalId),
}
#[derive(thiserror::Error, Debug)]
#[error("The hosts file is invalid")]
pub struct InvalidHostFile;
#[derive(thiserror::Error, Debug)]
pub enum CertificateInteractionError {
#[error("A Certificate action was already sent for a CertificateInteractionEvent")]
CertificateActionAlreadyApplied,
#[error("Lock acquisition failure")]
LockAcquisitionFailure,
#[error("Quinnet async channel error")]
AsyncChannelError(#[from] AsyncChannelError),
}
impl<T> From<PoisonError<T>> for CertificateInteractionError {
fn from(_: PoisonError<T>) -> Self {
Self::LockAcquisitionFailure
}
}