diff --git a/src/error.rs b/src/error.rs index 481cf3268..6bb94af56 100644 --- a/src/error.rs +++ b/src/error.rs @@ -293,8 +293,18 @@ impl From 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 {