1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-08-30 19:10:20 +02:00

add ErrorResponse impl for TimeoutError

This commit is contained in:
Nikolay Kim
2019-02-11 09:54:41 -08:00
parent e178db7f74
commit f9724fa0ec
2 changed files with 12 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ use std::string::FromUtf8Error;
use std::{fmt, io, result};
// use actix::MailboxError;
use actix_utils::timeout::TimeoutError;
use backtrace::Backtrace;
use cookie;
use derive_more::{Display, From};
@@ -187,6 +188,16 @@ impl<T: ResponseError + 'static> From<T> for Error {
// }
// }
/// Return `GATEWAY_TIMEOUT` for `TimeoutError`
impl<E: ResponseError> ResponseError for TimeoutError<E> {
fn error_response(&self) -> Response {
match self {
TimeoutError::Service(e) => e.error_response(),
TimeoutError::Timeout => Response::new(StatusCode::GATEWAY_TIMEOUT),
}
}
}
/// `InternalServerError` for `JsonError`
impl ResponseError for JsonError {}