pub trait ResponseError: Debug + Display {
// Provided methods
fn status_code(&self) -> StatusCode { ... }
fn error_response(&self) -> HttpResponse<BoxBody> { ... }
}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<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§
Source§impl dyn ResponseError + 'static
impl dyn ResponseError + 'static
Sourcepub fn downcast_ref<T: ResponseError + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: ResponseError + 'static>(&self) -> Option<&T>
Downcasts generic body to a specific type.
Sourcepub fn downcast_mut<T: ResponseError + 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: ResponseError + 'static>(&mut self) -> Option<&mut T>
Downcasts a generic body to a mutable specific type.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
impl ResponseError for Box<dyn StdError + 'static>
impl ResponseError for Error
Available on crate feature
openssl only.Source§impl ResponseError for Error
impl ResponseError for Error
fn status_code(&self) -> StatusCode
impl ResponseError for Error
impl ResponseError for Error
Source§impl ResponseError for Error
impl ResponseError for Error
fn status_code(&self) -> StatusCode
Source§impl ResponseError for HandshakeError
Available on crate feature ws only.
impl ResponseError for HandshakeError
Available on crate feature
ws only.fn error_response(&self) -> HttpResponse<BoxBody>
Source§impl ResponseError for Infallible
impl ResponseError for Infallible
fn status_code(&self) -> StatusCode
fn error_response(&self) -> HttpResponse<BoxBody>
impl ResponseError for ProtocolError
Available on crate feature
ws only.Source§impl ResponseError for Utf8Error
impl ResponseError for Utf8Error
fn status_code(&self) -> StatusCode
Implementors§
impl ResponseError for BlockingError
impl ResponseError for ContentTypeError
impl ResponseError for actix_web::http::Error
impl ResponseError for HttpError
impl ResponseError for InvalidHeaderValue
impl ResponseError for JsonPayloadError
impl ResponseError for ParseError
impl ResponseError for PathError
Return BadRequest for PathError