mirror of
https://github.com/actix/actix-web.git
synced 2025-01-20 14:08:07 +00:00
Implement ResponseError
for Infallible
(#2769)
This commit is contained in:
parent
6a5b370206
commit
dce57a79c9
3 changed files with 11 additions and 6 deletions
|
@ -5,6 +5,7 @@
|
||||||
- Add `ServiceRequest::extract()` to make it easier to use extractors when writing middlewares. [#2647]
|
- 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 `Route::wrap()` to allow individual routes to use middleware. [#2725]
|
||||||
- Add `ServiceConfig::default_service()`. [#2338] [#2743]
|
- Add `ServiceConfig::default_service()`. [#2338] [#2743]
|
||||||
|
- Implement `ResponseError` for `std::convert::Infallible`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Clear connection-level data on `HttpRequest` drop. [#2742]
|
- Clear connection-level data on `HttpRequest` drop. [#2742]
|
||||||
|
|
|
@ -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`
|
/// `Error` for any error that implements `ResponseError`
|
||||||
impl<T: ResponseError + 'static> From<T> for Error {
|
impl<T: ResponseError + 'static> From<T> for Error {
|
||||||
fn from(err: T) -> Error {
|
fn from(err: T) -> Error {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! `ResponseError` trait and foreign impls.
|
//! `ResponseError` trait and foreign impls.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
convert::Infallible,
|
||||||
error::Error as StdError,
|
error::Error as StdError,
|
||||||
fmt,
|
fmt,
|
||||||
io::{self, Write as _},
|
io::{self, Write as _},
|
||||||
|
@ -54,6 +55,15 @@ downcast_dyn!(ResponseError);
|
||||||
|
|
||||||
impl ResponseError for Box<dyn StdError + 'static> {}
|
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")]
|
#[cfg(feature = "openssl")]
|
||||||
impl ResponseError for actix_tls::accept::openssl::reexports::Error {}
|
impl ResponseError for actix_tls::accept::openssl::reexports::Error {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue