From 1a80b70868a79cc5fc03f04b105adac7bae36769 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 5 Mar 2019 19:41:50 -0800 Subject: [PATCH] add Responder impl for InternalError --- src/responder.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/responder.rs b/src/responder.rs index b2fd848f0..dedfa1b44 100644 --- a/src/responder.rs +++ b/src/responder.rs @@ -1,3 +1,4 @@ +use actix_http::error::InternalError; use actix_http::{dev::ResponseBuilder, http::StatusCode, Error, Response}; use bytes::{Bytes, BytesMut}; use futures::future::{err, ok, Either as EitherFuture, FutureResult}; @@ -252,6 +253,18 @@ where } } +impl Responder for InternalError +where + T: std::fmt::Debug + std::fmt::Display + 'static, +{ + type Error = Error; + type Future = Result; + + fn respond_to(self, _: &HttpRequest) -> Self::Future { + Err(self.into()) + } +} + pub struct ResponseFuture(T); impl ResponseFuture {