Struct HandleError

pub struct HandleError<S, F, T> { /* private fields */ }

A Service adapter that handles errors by converting them into responses.

See module docs for more details on axum's error handling model.

Implementations

impl<S, F, T> HandleError<S, F, T>

fn new(inner: S, f: F) -> Self

Create a new HandleError.

Trait Implementations

impl<S, F, B, Fut, Res> Service<Request<B>> for HandleError<S, F, ()> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1> Service<Request<B>> for HandleError<S, F, (T1,)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2> Service<Request<B>> for HandleError<S, F, (T1, T2)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3> Service<Request<B>> for HandleError<S, F, (T1, T2, T3)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, T12: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, T12: FromRequestParts<()> + Send, T13: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, T12: FromRequestParts<()> + Send, T13: FromRequestParts<()> + Send, T14: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, T12: FromRequestParts<()> + Send, T13: FromRequestParts<()> + Send, T14: FromRequestParts<()> + Send, T15: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, B, Res, Fut, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Service<Request<B>> for HandleError<S, F, (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16)> where S: Service<Request<B>> + Clone + Send + 'static, S::Response: IntoResponse + Send, S::Error: Send, S::Future: Send, F: FnOnce(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, S::Error) -> Fut + Clone + Send + 'static, Fut: Future<Output = Res> + Send, Res: IntoResponse, T1: FromRequestParts<()> + Send, T2: FromRequestParts<()> + Send, T3: FromRequestParts<()> + Send, T4: FromRequestParts<()> + Send, T5: FromRequestParts<()> + Send, T6: FromRequestParts<()> + Send, T7: FromRequestParts<()> + Send, T8: FromRequestParts<()> + Send, T9: FromRequestParts<()> + Send, T10: FromRequestParts<()> + Send, T11: FromRequestParts<()> + Send, T12: FromRequestParts<()> + Send, T13: FromRequestParts<()> + Send, T14: FromRequestParts<()> + Send, T15: FromRequestParts<()> + Send, T16: FromRequestParts<()> + Send, B: Send + 'static,

type Response = Response<Body>;
type Error = never;
type Future = HandleErrorFuture;
fn poll_ready(&mut self, &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, req: Request<B>) -> Self::Future

impl<S, F, E> Debug for HandleError<S, F, E> where S: Debug,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<S, F, T> Clone for HandleError<S, F, T> where S: Clone, F: Clone,

fn clone(&self) -> Self

Auto Trait Implementations

impl<S, F, T> Freeze for HandleError<S, F, T> where S: Freeze, F: Freeze, PhantomData<fn() -> T>: Freeze,

impl<S, F, T> RefUnwindSafe for HandleError<S, F, T> where S: RefUnwindSafe, F: RefUnwindSafe, PhantomData<fn() -> T>: RefUnwindSafe,

impl<S, F, T> Send for HandleError<S, F, T> where S: Send, F: Send, PhantomData<fn() -> T>: Send,

impl<S, F, T> Sync for HandleError<S, F, T> where S: Sync, F: Sync, PhantomData<fn() -> T>: Sync,

impl<S, F, T> Unpin for HandleError<S, F, T> where S: Unpin, F: Unpin, PhantomData<fn() -> T>: Unpin,

impl<S, F, T> UnsafeUnpin for HandleError<S, F, T> where S: UnsafeUnpin, F: UnsafeUnpin, PhantomData<fn() -> T>: UnsafeUnpin,

impl<S, F, T> UnwindSafe for HandleError<S, F, T> where S: UnwindSafe, F: UnwindSafe, PhantomData<fn() -> T>: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for HandleError<S, F, T> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

type Connection = <C as Service<Target>>::Response;
type Error = <C as Service<Target>>::Error;
type Future = <C as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>
fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future

impl<M, S, Target, Request> MakeService<Target, Request> for HandleError<S, F, T> where M: Service<Target, Response = S>, S: Service<Request>,

type Response = <S as Service<Request>>::Response;
type Error = <S as Service<Request>>::Error;
type Service = S;
type MakeError = <M as Service<Target>>::Error;
type Future = <M as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future

impl<S, R> ServiceExt<R> for HandleError<S, F, T> where S: Service<R>,

fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service_with_connect_info<C>(self) -> IntoMakeServiceWithConnectInfo<S, C>

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for HandleError<S, F, T> where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for HandleError<S, F, T> where ST: ?Sized, DT: ?Sized,

impl<T> Any for HandleError<S, F, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for HandleError<S, F, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for HandleError<S, F, T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for HandleError<S, F, T> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for HandleError<S, F, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FromRef<T> for HandleError<S, F, T> where T: Clone,

fn from_ref(input: &T) -> T

impl<T> Instrument for HandleError<S, F, T>

impl<T> Read<Exclusive, BecauseExclusive> for HandleError<S, F, T> where T: ?Sized,

impl<T> Same for HandleError<S, F, T>

type Output = T;

impl<T> ToOwned for HandleError<S, F, T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for HandleError<S, F, T>

impl<T, Request> ServiceExt<Request> for HandleError<S, F, T> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for HandleError<S, F, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for HandleError<S, F, T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for HandleError<S, F, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

impl<V, T> VZip<V> for HandleError<S, F, T> where V: MultiLane<T>,

fn vzip(self) -> V