mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
Merge pull request #270 from DoumanAsh/payload_err
Specialize ResponseError for PayloadError
This commit is contained in:
commit
8c7182f6e6
14
src/error.rs
14
src/error.rs
@ -293,8 +293,18 @@ impl From<IoError> for PayloadError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `InternalServerError` for `PayloadError`
|
/// `PayloadError` returns two possible results:
|
||||||
impl ResponseError for PayloadError {}
|
///
|
||||||
|
/// - `Overflow` returns `PayloadTooLarge`
|
||||||
|
/// - Other errors returns `BadRequest`
|
||||||
|
impl ResponseError for PayloadError {
|
||||||
|
fn error_response(&self) -> HttpResponse {
|
||||||
|
match *self {
|
||||||
|
PayloadError::Overflow => HttpResponse::new(StatusCode::PAYLOAD_TOO_LARGE),
|
||||||
|
_ => HttpResponse::new(StatusCode::BAD_REQUEST)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Return `BadRequest` for `cookie::ParseError`
|
/// Return `BadRequest` for `cookie::ParseError`
|
||||||
impl ResponseError for cookie::ParseError {
|
impl ResponseError for cookie::ParseError {
|
||||||
|
Loading…
Reference in New Issue
Block a user