1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00
actix-web/awc/src/error.rs

50 lines
1.6 KiB
Rust
Raw Normal View History

2019-03-28 02:53:19 +01:00
//! Http client errors
pub use actix_http::client::{ConnectError, InvalidUrl, SendRequestError};
pub use actix_http::error::PayloadError;
pub use actix_http::ws::HandshakeError as WsHandshakeError;
2019-03-28 02:53:19 +01:00
pub use actix_http::ws::ProtocolError as WsProtocolError;
2019-03-28 02:53:19 +01:00
use actix_http::http::{header::HeaderValue, Error as HttpError, StatusCode};
2018-12-20 03:34:56 +01:00
use derive_more::{Display, From};
/// Websocket client error
2018-12-20 03:34:56 +01:00
#[derive(Debug, Display, From)]
2019-03-28 02:53:19 +01:00
pub enum WsClientError {
/// 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),
/// Protocol error
2018-12-20 03:34:56 +01:00
#[display(fmt = "{}", _0)]
2019-03-28 02:53:19 +01:00
Protocol(WsProtocolError),
/// Send request error
2018-12-20 03:34:56 +01:00
#[display(fmt = "{}", _0)]
2019-03-28 02:53:19 +01:00
SendRequest(SendRequestError),
}
impl From<InvalidUrl> for WsClientError {
fn from(err: InvalidUrl) -> Self {
WsClientError::SendRequest(err.into())
}
}
impl From<HttpError> for WsClientError {
fn from(err: HttpError) -> Self {
WsClientError::SendRequest(err.into())
}
}