1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-28 01:52:57 +01:00
actix-web/actix-http/src/ws/client/error.rs

54 lines
1.6 KiB
Rust
Raw Normal View History

//! Http client request
use std::io;
2019-03-13 22:41:40 +01:00
use actix_connect::ConnectError;
2018-12-20 03:34:56 +01:00
use derive_more::{Display, From};
2018-12-06 23:32:52 +01:00
use http::{header::HeaderValue, Error as HttpError, StatusCode};
2018-12-06 23:32:52 +01:00
use crate::error::ParseError;
use crate::ws::ProtocolError;
/// Websocket client error
2018-12-20 03:34:56 +01:00
#[derive(Debug, Display, From)]
pub enum ClientError {
/// Invalid url
2018-12-20 03:34:56 +01:00
#[display(fmt = "Invalid url")]
InvalidUrl,
/// Invalid response status
2018-12-20 03:34:56 +01:00
#[display(fmt = "Invalid response status")]
InvalidResponseStatus(StatusCode),
/// Invalid upgrade header
2018-12-20 03:34:56 +01:00
#[display(fmt = "Invalid upgrade header")]
InvalidUpgradeHeader,
/// Invalid connection header
2018-12-20 03:34:56 +01:00
#[display(fmt = "Invalid connection header")]
InvalidConnectionHeader(HeaderValue),
/// Missing CONNECTION header
2018-12-20 03:34:56 +01:00
#[display(fmt = "Missing CONNECTION header")]
MissingConnectionHeader,
/// Missing SEC-WEBSOCKET-ACCEPT header
2018-12-20 03:34:56 +01:00
#[display(fmt = "Missing SEC-WEBSOCKET-ACCEPT header")]
MissingWebSocketAcceptHeader,
/// Invalid challenge response
2018-12-20 03:34:56 +01:00
#[display(fmt = "Invalid challenge response")]
InvalidChallengeResponse(String, HeaderValue),
/// Http parsing error
2018-12-20 03:34:56 +01:00
#[display(fmt = "Http parsing error")]
Http(HttpError),
/// Response parsing error
2018-12-20 03:34:56 +01:00
#[display(fmt = "Response parsing error: {}", _0)]
ParseError(ParseError),
/// Protocol error
2018-12-20 03:34:56 +01:00
#[display(fmt = "{}", _0)]
Protocol(ProtocolError),
/// Connect error
2018-12-20 03:34:56 +01:00
#[display(fmt = "Connector error: {:?}", _0)]
2019-03-13 22:41:40 +01:00
Connect(ConnectError),
/// IO Error
2018-12-20 03:34:56 +01:00
#[display(fmt = "{}", _0)]
Io(io::Error),
/// "Disconnected"
2018-12-20 03:34:56 +01:00
#[display(fmt = "Disconnected")]
Disconnected,
}