pub trait ResponseError: Debug + Display {
fn status_code(&self) -> StatusCode { ... }
fn error_response(&self) -> HttpResponse<BoxBody> { ... }
}Expand description
Errors that can generate responses.
Provided Methods
fn 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.
fn error_response(&self) -> HttpResponse<BoxBody>
fn error_response(&self) -> HttpResponse<BoxBody>
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
sourceimpl dyn ResponseError + 'static
impl dyn ResponseError + 'static
sourcepub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + ResponseError,
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + ResponseError,
Downcasts generic body to a specific type.
sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + ResponseError,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + ResponseError,
Downcasts a generic body to a mutable specific type.
Implementations on Foreign Types
sourceimpl ResponseError for Utf8Error
impl ResponseError for Utf8Error
fn status_code(&self) -> StatusCode
impl ResponseError for Box<dyn Error + 'static, Global>
sourceimpl ResponseError for Error
impl ResponseError for Error
fn status_code(&self) -> StatusCode
impl ResponseError for Error
sourceimpl ResponseError for Infallible
impl ResponseError for Infallible
fn status_code(&self) -> StatusCode
fn error_response(&self) -> HttpResponse<BoxBody>
impl ResponseError for Error
impl ResponseError for ProtocolError
sourceimpl ResponseError for PayloadError
impl ResponseError for PayloadError
fn status_code(&self) -> StatusCode
sourceimpl ResponseError for Error
impl ResponseError for Error
fn status_code(&self) -> StatusCode
sourceimpl ResponseError for HandshakeError
impl ResponseError for HandshakeError
fn error_response(&self) -> HttpResponse<BoxBody>
sourceimpl ResponseError for ParseError
impl ResponseError for ParseError
fn status_code(&self) -> StatusCode
impl ResponseError for Error
sourceimpl ResponseError for ContentTypeError
impl ResponseError for ContentTypeError
fn status_code(&self) -> StatusCode
Implementors
impl ResponseError for CustomError
impl ResponseError for JsonPayloadError
impl ResponseError for PathError
Return BadRequest for PathError