use thiserror::Error;
use crate::CloseEvent;
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum WsErr {
#[error("Invalid input to conversion to WsReadyState: {supplied}")]
InvalidWsState {
supplied: u16,
},
#[error("The connection state is not \"Open\".")]
ConnectionNotOpen,
#[error("An invalid URL was given to the connect method: {supplied}")]
InvalidUrl {
supplied: String,
},
#[error("An invalid close code was given to a close method: {supplied}")]
InvalidCloseCode {
supplied: u16,
},
#[error("The reason string given to a close method is to long.")]
ReasonStringToLong,
#[error("Failed to connect to the server. CloseEvent: {event:?}")]
ConnectionFailed {
event: CloseEvent,
},
#[error("Received a String message that couldn't be decoded to valid UTF-8")]
InvalidEncoding,
#[error("Received a Blob message that couldn't converted.")]
CantDecodeBlob,
#[error("Received a message that is neither ArrayBuffer, String or Blob.")]
UnknownDataType,
#[error("DOM Exception: {0}")]
Dom(u16),
#[error("{0}")]
Other(String),
}