summaryrefslogtreecommitdiffstats
path: root/ipfs-api/src/response/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ipfs-api/src/response/error.rs')
-rw-r--r--ipfs-api/src/response/error.rs41
1 files changed, 39 insertions, 2 deletions
diff --git a/ipfs-api/src/response/error.rs b/ipfs-api/src/response/error.rs
index 94f7fa9..ca69de6 100644
--- a/ipfs-api/src/response/error.rs
+++ b/ipfs-api/src/response/error.rs
@@ -5,8 +5,10 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
//
-
+#[cfg(feature = "actix")]
+use actix_web;
use http;
+#[cfg(feature = "hyper")]
use hyper;
use serde_json;
use serde_urlencoded;
@@ -23,10 +25,23 @@ pub struct ApiError {
#[derive(Fail, Debug)]
pub enum Error {
- // Foreign errors.
+ /// Foreign errors.
+ #[cfg(feature = "hyper")]
#[fail(display = "hyper client error '{}'", _0)]
Client(hyper::Error),
+ #[cfg(feature = "actix")]
+ #[fail(display = "actix client error '{}'", _0)]
+ Client(actix_web::error::Error),
+
+ #[cfg(feature = "actix")]
+ #[fail(display = "actix client payload error '{}'", _0)]
+ ClientPayload(actix_web::error::PayloadError),
+
+ #[cfg(feature = "actix")]
+ #[fail(display = "actix client send request error '{}'", _0)]
+ ClientSend(actix_web::client::SendRequestError),
+
#[fail(display = "http error '{}'", _0)]
Http(http::Error),
@@ -61,12 +76,34 @@ pub enum Error {
Uncategorized(String),
}
+#[cfg(feature = "hyper")]
impl From<hyper::Error> for Error {
fn from(err: hyper::Error) -> Error {
Error::Client(err)
}
}
+#[cfg(feature = "actix")]
+impl From<actix_web::error::Error> for Error {
+ fn from(err: actix_web::error::Error) -> Error {
+ Error::Client(err)
+ }
+}
+
+#[cfg(feature = "actix")]
+impl From<actix_web::client::SendRequestError> for Error {
+ fn from(err: actix_web::client::SendRequestError) -> Error {
+ Error::ClientSend(err)
+ }
+}
+
+#[cfg(feature = "actix")]
+impl From<actix_web::error::PayloadError> for Error {
+ fn from(err: actix_web::error::PayloadError) -> Error {
+ Error::ClientPayload(err)
+ }
+}
+
impl From<http::Error> for Error {
fn from(err: http::Error) -> Error {
Error::Http(err)