pub trait ResponseError: Debug + Display {
// Provided methods
fn status_code(&self) -> StatusCode { ... }
fn error_response(&self) -> HttpResponse { ... }
}
Expand description
Errors that can generate responses.
Provided Methods§
Sourcefn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Returns appropriate status code for error.
A 500 Internal Server Error is used by default. If error_response is
also implemented and does not call self.status_code()
, then this will not be used.
Sourcefn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Creates full response for error.
By default, the generated response uses a 500 Internal Server Error status code, a
Content-Type
of text/plain
, and the body is set to Self
’s Display
impl.
Implementations§
Source§impl dyn ResponseError
impl dyn ResponseError
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ResponseError + 'static,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ResponseError + 'static,
Downcasts generic body to a specific type.
Sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: ResponseError + 'static,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: ResponseError + 'static,
Downcasts a generic body to a mutable specific type.
Implementations on Foreign Types§
Source§impl ResponseError for Infallible
impl ResponseError for Infallible
fn status_code(&self) -> StatusCode
fn error_response(&self) -> HttpResponse
Source§impl ResponseError for CorsError
impl ResponseError for CorsError
fn status_code(&self) -> StatusCode
fn error_response(&self) -> HttpResponse
Source§impl ResponseError for HandshakeError
impl ResponseError for HandshakeError
fn error_response(&self) -> HttpResponse
impl ResponseError for ProtocolError
impl ResponseError for Error
impl ResponseError for Box<dyn Error>
Source§impl ResponseError for Utf8Error
impl ResponseError for Utf8Error
fn status_code(&self) -> StatusCode
Implementors§
impl ResponseError for ContentTypeError
impl ResponseError for JsonPayloadError
impl ResponseError for ParseError
impl ResponseError for PathError
Return BadRequest
for PathError