1use std::array::TryFromSliceError;
2use std::io;
3use thiserror::Error;
4use url::ParseError;
5
6#[derive(Error, Debug)]
7pub enum Error {
8 #[error("the peer has sent the close frame: status code {0}, body: {1}")]
9 ReceivedCloseFrame(u16, String),
10 #[error("websocket protocol error: {0}")]
11 Protocol(String),
12 #[error("the websocket is closed and can be dropped")]
13 Closed,
14 #[error("IO error: {0}")]
15 IO(#[from] io::Error),
16 #[error("url parse error: {0}")]
17 InvalidUrl(#[from] ParseError),
18 #[error("slice error: {0}")]
19 SliceError(#[from] TryFromSliceError),
20}
21
22impl From<Error> for io::Error {
23 fn from(value: Error) -> Self {
24 io::Error::other(value)
25 }
26}