1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

Merge pull request #270 from DoumanAsh/payload_err

Specialize ResponseError for PayloadError
This commit is contained in:
Nikolay Kim 2018-06-02 15:06:55 -07:00 committed by GitHub
commit 8c7182f6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -293,8 +293,18 @@ impl From<IoError> for PayloadError {
}
}
/// `InternalServerError` for `PayloadError`
impl ResponseError for PayloadError {}
/// `PayloadError` returns two possible results:
///
/// - `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`
impl ResponseError for cookie::ParseError {