1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

remove default impl for std error, it prevents use of Fail

This commit is contained in:
Nikolay Kim 2018-02-07 13:57:58 -08:00
parent 81e4fb9353
commit 93aa220e8d

View File

@ -4,11 +4,9 @@ use std::str::Utf8Error;
use std::string::FromUtf8Error; use std::string::FromUtf8Error;
use std::io::Error as IoError; use std::io::Error as IoError;
#[cfg(actix_nightly)]
use std::error::Error as StdError;
use cookie; use cookie;
use httparse; use httparse;
use actix::MailboxError;
use futures::Canceled; use futures::Canceled;
use failure; use failure;
use failure::{Fail, Backtrace}; use failure::{Fail, Backtrace};
@ -96,6 +94,7 @@ impl<T: ResponseError> From<T> for Error {
} }
} }
/// Compatibility for `failure::Error`
impl<T> ResponseError for failure::Compat<T> impl<T> ResponseError for failure::Compat<T>
where T: fmt::Display + fmt::Debug + Sync + Send + 'static where T: fmt::Display + fmt::Debug + Sync + Send + 'static
{ } { }
@ -106,14 +105,6 @@ impl From<failure::Error> for Error {
} }
} }
/// Default error is `InternalServerError`
#[cfg(actix_nightly)]
default impl<T: StdError + Sync + Send + 'static> ResponseError for T {
fn error_response(&self) -> HttpResponse {
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty)
}
}
/// `InternalServerError` for `JsonError` /// `InternalServerError` for `JsonError`
impl ResponseError for JsonError {} impl ResponseError for JsonError {}
@ -145,6 +136,9 @@ impl ResponseError for header::InvalidHeaderValue {}
/// `InternalServerError` for `futures::Canceled` /// `InternalServerError` for `futures::Canceled`
impl ResponseError for Canceled {} impl ResponseError for Canceled {}
/// `InternalServerError` for `actix::MailboxError`
impl ResponseError for MailboxError {}
/// A set of errors that can occur during parsing HTTP streams /// A set of errors that can occur during parsing HTTP streams
#[derive(Fail, Debug)] #[derive(Fail, Debug)]
pub enum ParseError { pub enum ParseError {