diff --git a/Cargo.toml b/Cargo.toml index 1adae97b8..f4170f28a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ members = [ ] [features] -default = ["compress", "failure"] +default = ["compress", "failure", "anyhow"] # content-encoding support compress = ["actix-http/compress", "awc/compress"] @@ -51,6 +51,7 @@ compress = ["actix-http/compress", "awc/compress"] secure-cookies = ["actix-http/secure-cookies"] failure = ["actix-http/failure"] +anyhow = ["actix-http/anyhow"] # openssl openssl = ["actix-tls/openssl", "awc/openssl", "open-ssl"] diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index 367dbafec..dec7e49f3 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -15,7 +15,7 @@ license = "MIT/Apache-2.0" edition = "2018" [package.metadata.docs.rs] -features = ["openssl", "rustls", "failure", "compress", "secure-cookies"] +features = ["openssl", "rustls", "failure", "compress", "secure-cookies", "anyhow"] [lib] name = "actix_http" @@ -36,6 +36,8 @@ compress = ["flate2", "brotli2"] # failure integration. actix does not use failure anymore failure = ["fail-ure"] +anyhow = ["any-how"] + # support for secure cookies secure-cookies = ["ring"] @@ -88,6 +90,7 @@ flate2 = { version = "1.0.13", optional = true } # optional deps fail-ure = { version = "0.1.5", package="failure", optional = true } +any-how = { version="1.0", package="anyhow", optional = true } [dev-dependencies] actix-server = "1.0.0" diff --git a/actix-http/src/error.rs b/actix-http/src/error.rs index fd0fe927f..a97c40444 100644 --- a/actix-http/src/error.rs +++ b/actix-http/src/error.rs @@ -36,8 +36,8 @@ pub type Result = result::Result; /// General purpose actix web error. /// -/// An actix web error is used to carry errors from `failure` or `std::error` -/// through actix in a convenient way. It can be created through +/// An actix web error is used to carry errors from `anyhow`, `failure`, or +/// `std::error` through actix in a convenient way. It can be created through /// converting errors with `into()`. /// /// Whenever it is created from an external object a response error is created @@ -967,6 +967,10 @@ where /// Compatibility for `failure::Error` impl ResponseError for fail_ure::Error {} +#[cfg(feature = "anyhow")] +/// Compatibility for `anyhow::Error` +impl ResponseError for any_how::Error {} + #[cfg(test)] mod tests { use super::*;