1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00:00

Implement ResponseError for Infallible (#2769)

This commit is contained in:
Sabrina Jewson 2022-05-30 20:52:48 +01:00 committed by GitHub
parent 6a5b370206
commit dce57a79c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -5,6 +5,7 @@
- Add `ServiceRequest::extract()` to make it easier to use extractors when writing middlewares. [#2647]
- Add `Route::wrap()` to allow individual routes to use middleware. [#2725]
- Add `ServiceConfig::default_service()`. [#2338] [#2743]
- Implement `ResponseError` for `std::convert::Infallible`
### Fixed
- Clear connection-level data on `HttpRequest` drop. [#2742]

View file

@ -51,12 +51,6 @@ impl StdError for Error {
}
}
impl From<std::convert::Infallible> for Error {
fn from(val: std::convert::Infallible) -> Self {
match val {}
}
}
/// `Error` for any error that implements `ResponseError`
impl<T: ResponseError + 'static> From<T> for Error {
fn from(err: T) -> Error {

View file

@ -1,6 +1,7 @@
//! `ResponseError` trait and foreign impls.
use std::{
convert::Infallible,
error::Error as StdError,
fmt,
io::{self, Write as _},
@ -54,6 +55,15 @@ downcast_dyn!(ResponseError);
impl ResponseError for Box<dyn StdError + 'static> {}
impl ResponseError for Infallible {
fn status_code(&self) -> StatusCode {
match *self {}
}
fn error_response(&self) -> HttpResponse<BoxBody> {
match *self {}
}
}
#[cfg(feature = "openssl")]
impl ResponseError for actix_tls::accept::openssl::reexports::Error {}