mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 08:45:10 +02:00
refined error model (#2253)
This commit is contained in:
@ -50,7 +50,7 @@ where
|
||||
T: Transform<S, Req>,
|
||||
T::Future: 'static,
|
||||
T::Response: MapServiceResponseBody,
|
||||
Error: From<T::Error>,
|
||||
T::Error: Into<Error>,
|
||||
{
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -75,7 +75,7 @@ impl<S, Req> Service<Req> for CompatMiddleware<S>
|
||||
where
|
||||
S: Service<Req>,
|
||||
S::Response: MapServiceResponseBody,
|
||||
Error: From<S::Error>,
|
||||
S::Error: Into<Error>,
|
||||
{
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
@ -99,12 +99,16 @@ impl<Fut, T, E> Future for CompatMiddlewareFuture<Fut>
|
||||
where
|
||||
Fut: Future<Output = Result<T, E>>,
|
||||
T: MapServiceResponseBody,
|
||||
Error: From<E>,
|
||||
E: Into<Error>,
|
||||
{
|
||||
type Output = Result<ServiceResponse, Error>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let res = ready!(self.project().fut.poll(cx))?;
|
||||
let res = match ready!(self.project().fut.poll(cx)) {
|
||||
Ok(res) => res,
|
||||
Err(err) => return Poll::Ready(Err(err.into())),
|
||||
};
|
||||
|
||||
Poll::Ready(Ok(res.map_body()))
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ use actix_http::{
|
||||
body::{MessageBody, ResponseBody},
|
||||
encoding::Encoder,
|
||||
http::header::{ContentEncoding, ACCEPT_ENCODING},
|
||||
Error,
|
||||
};
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_utils::future::{ok, Ready};
|
||||
@ -23,6 +22,7 @@ use pin_project::pin_project;
|
||||
use crate::{
|
||||
dev::BodyEncoding,
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
Error,
|
||||
};
|
||||
|
||||
/// Middleware for compressing response payloads.
|
||||
|
@ -13,8 +13,8 @@ use futures_core::{future::LocalBoxFuture, ready};
|
||||
|
||||
use crate::{
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
error::{Error, Result},
|
||||
http::StatusCode,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// Return type for [`ErrorHandlers`] custom handlers.
|
||||
|
Reference in New Issue
Block a user