1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 00:50:20 +02:00

added urlencoded errors

This commit is contained in:
Nikolay Kim
2017-11-26 22:00:25 -08:00
parent fdafb0c848
commit 8e80fed2af
2 changed files with 54 additions and 27 deletions

View File

@@ -344,6 +344,31 @@ impl ErrorResponse for WsHandshakeError {
}
}
/// A set of errors that can occur during parsing urlencoded payloads
#[derive(Fail, Debug, PartialEq)]
pub enum UrlencodedError {
/// Can not decode chunked transfer encoding
#[fail(display="Can not decode chunked transfer encoding")]
Chunked,
/// Payload size is bigger than 256k
#[fail(display="Payload size is bigger than 256k")]
Overflow,
/// Payload size is now known
#[fail(display="Payload size is now known")]
UnknownLength,
/// Content type error
#[fail(display="Content type error")]
ContentType,
}
/// Return `BadRequest` for `UrlencodedError`
impl ErrorResponse for UrlencodedError {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::BAD_REQUEST, Body::Empty)
}
}
#[cfg(test)]
mod tests {
use std::error::Error as StdError;