Skip to main content

HttpErrorHandler

Trait HttpErrorHandler 

Source
pub trait HttpErrorHandler {
    // Required method
    fn on_error(&self, error: &HttpError<'_>, response: &mut Response);
}
Expand description

Application-level rewriting of failure responses.

Handlers run in registration order after dispatch has produced a failure response and before middleware on_response, so an application can give every failure one house style without touching the typed errors each operation declares.

The status of a HttpErrorSource::Domain failure is restored after the handlers run: a #[api_error] variant publishes its status in the contract, and this seam must not make that published status a lie. Body, headers, and the status of every other source are the handler’s to change.

A response a middleware layer returns to short-circuit dispatch is that layer’s own and does not reach these handlers; the layer shapes it in HttpMiddleware::on_response.

Required Methods§

Source

fn on_error(&self, error: &HttpError<'_>, response: &mut Response)

Rewrites one failure response.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§