mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 09:59:21 +02:00
better nightly detection
This commit is contained in:
17
src/error.rs
17
src/error.rs
@ -4,7 +4,7 @@ use std::str::Utf8Error;
|
||||
use std::string::FromUtf8Error;
|
||||
use std::io::Error as IoError;
|
||||
|
||||
#[cfg(feature="nightly")]
|
||||
#[cfg(actix_nightly)]
|
||||
use std::error::Error as StdError;
|
||||
|
||||
use cookie;
|
||||
@ -76,11 +76,11 @@ impl<T: ErrorResponse> From<T> for Error {
|
||||
}
|
||||
|
||||
/// Default error is `InternalServerError`
|
||||
#[cfg(feature="nightly")]
|
||||
#[cfg(actix_nightly)]
|
||||
default impl<T: StdError + Sync + Send + 'static> ErrorResponse for T {
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty)
|
||||
}
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
HttpResponse::new(StatusCode::INTERNAL_SERVER_ERROR, Body::Empty)
|
||||
}
|
||||
}
|
||||
|
||||
/// `InternalServerError` for `JsonError`
|
||||
@ -343,6 +343,13 @@ mod tests {
|
||||
use cookie::ParseError as CookieParseError;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(actix_nightly)]
|
||||
fn test_nightly() {
|
||||
let resp: HttpResponse = IoError::new(io::ErrorKind::Other, "test").error_response();
|
||||
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_into_response() {
|
||||
let resp: HttpResponse = ParseError::Incomplete.error_response();
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Web framework for [Actix](https://github.com/actix/actix)
|
||||
|
||||
#![cfg_attr(feature="nightly", feature(
|
||||
#![cfg_attr(actix_nightly, feature(
|
||||
specialization, // for impl ErrorResponse for std::error::Error
|
||||
))]
|
||||
|
||||
|
Reference in New Issue
Block a user