mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-31 00:50:20 +02:00
refactor ws frame parser
This commit is contained in:
30
src/error.rs
30
src/error.rs
@@ -236,8 +236,6 @@ pub enum PayloadError {
|
||||
|
||||
impl From<IoError> for PayloadError {
|
||||
fn from(err: IoError) -> PayloadError {
|
||||
use backtrace;
|
||||
println!("IO ERROR {:?}", backtrace::Backtrace::new());
|
||||
PayloadError::Io(err)
|
||||
}
|
||||
}
|
||||
@@ -391,6 +389,34 @@ impl ResponseError for WsHandshakeError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Websocket errors
|
||||
#[derive(Fail, Debug)]
|
||||
pub enum WsError {
|
||||
/// Received an unmasked frame from client
|
||||
#[fail(display="Received an unmasked frame from client")]
|
||||
UnmaskedFrame,
|
||||
/// Received a masked frame from server
|
||||
#[fail(display="Received a masked frame from server")]
|
||||
MaskedFrame,
|
||||
/// Encountered invalid opcode
|
||||
#[fail(display="Invalid opcode: {}", _0)]
|
||||
InvalidOpcode(u8),
|
||||
/// Invalid control frame length
|
||||
#[fail(display="Invalid control frame length: {}", _0)]
|
||||
InvalidLength(usize),
|
||||
/// Payload error
|
||||
#[fail(display="Payload error: {}", _0)]
|
||||
Payload(#[cause] PayloadError),
|
||||
}
|
||||
|
||||
impl ResponseError for WsError {}
|
||||
|
||||
impl From<PayloadError> for WsError {
|
||||
fn from(err: PayloadError) -> WsError {
|
||||
WsError::Payload(err)
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of errors that can occur during parsing urlencoded payloads
|
||||
#[derive(Fail, Debug)]
|
||||
pub enum UrlencodedError {
|
||||
|
Reference in New Issue
Block a user