Skip to main content

ResponseError

Trait ResponseError 

Source
pub trait ResponseError: Error {
    // Provided method
    fn error_response(&self) -> Response { ... }
}
Expand description

An error that can be converted into an HTTP Response.

Provided Methods§

Source

fn error_response(&self) -> Response

Creates an HTTP response for this error.

The default response has status 500 Internal Server Error, a text/plain; charset=utf-8 content type, and the error’s Display representation as its body. Implementations should override this method when that text is not suitable for clients.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ResponseError for Error

Return InternalServerError for io::Error

Source§

impl<T: ResponseError> ResponseError for &T

Implementors§

Source§

impl ResponseError for ntex::web::error::JsonError

InternalServerError for JsonError

Source§

impl ResponseError for HandshakeError

Source§

impl ResponseError for HttpError

Return InternalServerError for HttpError, Response generation can return HttpError, so it is internal error

Source§

impl ResponseError for ntex::http::h1::ProtocolError

Source§

impl ResponseError for ntex::ws::error::ProtocolError

Source§

impl<St, Err> ResponseError for WebError<St, Err>

Source§

impl<T> ResponseError for InternalError<T>
where T: Debug + Display + 'static,