1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-21 17:33:59 +00: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

@ -40,7 +40,7 @@ ssl = ["openssl"]
actix-service = "0.2.1"
actix-codec = "0.1.0"
actix-connector = "0.2.0"
actix-utils = "0.2.1"
actix-utils = "0.2.2"
base64 = "0.10"
backtrace = "0.3"
@ -80,7 +80,6 @@ openssl = { version="0.10", optional = true }
actix-rt = "0.1.0"
actix-server = { version="0.2", features=["ssl"] }
actix-connector = { version="0.2.0", features=["ssl"] }
actix-utils = "0.2.1"
actix-http-test = { path="test-server", features=["ssl"] }
env_logger = "0.6"
serde_derive = "1.0"

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 {}