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.rs161
1 files changed, 0 insertions, 161 deletions
diff --git a/ipfs-api/src/response/error.rs b/ipfs-api/src/response/error.rs
deleted file mode 100644
index 996a313..0000000
--- a/ipfs-api/src/response/error.rs
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright 2017 rust-ipfs-api Developers
-//
-// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
-// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
-// http://opensource.org/licenses/MIT>, at your option. This file may not be
-// copied, modified, or distributed except according to those terms.
-//
-
-use crate::serde::Deserialize;
-use std::string::FromUtf8Error;
-
-#[cfg_attr(feature = "with-actix", derive(Display), display(fmt = "{}", message))]
-#[cfg_attr(feature = "with-hyper", derive(Fail), fail(display = "{}", message))]
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "PascalCase")]
-pub struct ApiError {
- pub message: String,
- pub code: u8,
-}
-
-#[cfg_attr(feature = "with-actix", derive(Display))]
-#[cfg_attr(feature = "with-hyper", derive(Fail))]
-#[derive(Debug)]
-pub enum Error {
- /// Foreign errors.
- #[cfg(feature = "with-hyper")]
- #[cfg_attr(feature = "with-hyper", fail(display = "hyper client error '{}'", _0))]
- Client(hyper::Error),
-
- #[cfg(feature = "with-actix")]
- #[cfg_attr(
- feature = "with-actix",
- display(fmt = "actix client payload error '{}'", _0)
- )]
- ClientPayload(awc::error::PayloadError),
-
- #[cfg(feature = "with-actix")]
- #[cfg_attr(
- feature = "with-actix",
- display(fmt = "actix client send request error '{}'", _0)
- )]
- ClientSend(awc::error::SendRequestError),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "http error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "http error '{}'", _0))]
- Http(http::Error),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "json parse error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "json parse error '{}'", _0))]
- Parse(serde_json::Error),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "utf8 decoding error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "utf8 decoding error '{}'", _0))]
- ParseUtf8(FromUtf8Error),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "uri error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "uri error '{}'", _0))]
- Url(http::uri::InvalidUri),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "io error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "io error '{}'", _0))]
- Io(std::io::Error),
-
- #[cfg_attr(feature = "with-actix", display(fmt = "url encoding error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "url encoding error '{}'", _0))]
- EncodeUrl(serde_urlencoded::ser::Error),
-
- /// An error returned by the Ipfs api.
- #[cfg_attr(feature = "with-actix", display(fmt = "api returned error '{}'", _0))]
- #[cfg_attr(feature = "with-hyper", fail(display = "api returned error '{}'", _0))]
- Api(ApiError),
-
- /// A stream error indicated in the Trailer header.
- #[cfg_attr(
- feature = "with-actix",
- display(fmt = "api returned an error while streaming: '{}'", _0)
- )]
- #[cfg_attr(
- feature = "with-hyper",
- fail(display = "api returned an error while streaming: '{}'", _0)
- )]
- StreamError(String),
-
- /// API returned a trailer header with unrecognized value.
- #[cfg_attr(
- feature = "with-actix",
- display(fmt = "api returned a trailer header with unknown value: '{}'", _0)
- )]
- #[cfg_attr(
- feature = "with-hyper",
- fail(display = "api returned a trailer header with unknown value: '{}'", _0)
- )]
- UnrecognizedTrailerHeader(String),
-
- #[cfg_attr(
- feature = "with-actix",
- display(fmt = "api returned unknwon error '{}'", _0)
- )]
- #[cfg_attr(
- feature = "with-hyper",
- fail(display = "api returned unknwon error '{}'", _0)
- )]
- Uncategorized(String),
-}
-
-#[cfg(feature = "with-hyper")]
-impl From<hyper::Error> for Error {
- fn from(err: hyper::Error) -> Error {
- Error::Client(err)
- }
-}
-
-#[cfg(feature = "with-actix")]
-impl From<awc::error::SendRequestError> for Error {
- fn from(err: awc::error::SendRequestError) -> Error {
- Error::ClientSend(err)
- }
-}
-
-#[cfg(feature = "with-actix")]
-impl From<awc::error::PayloadError> for Error {
- fn from(err: awc::error::PayloadError) -> Error {
- Error::ClientPayload(err)
- }
-}
-
-impl From<http::Error> for Error {
- fn from(err: http::Error) -> Error {
- Error::Http(err)
- }
-}
-
-impl From<serde_json::Error> for Error {
- fn from(err: serde_json::Error) -> Error {
- Error::Parse(err)
- }
-}
-
-impl From<FromUtf8Error> for Error {
- fn from(err: FromUtf8Error) -> Error {
- Error::ParseUtf8(err)
- }
-}
-
-impl From<http::uri::InvalidUri> for Error {
- fn from(err: http::uri::InvalidUri) -> Error {
- Error::Url(err)
- }
-}
-
-impl From<std::io::Error> for Error {
- fn from(err: std::io::Error) -> Error {
- Error::Io(err)
- }
-}
-
-impl From<serde_urlencoded::ser::Error> for Error {
- fn from(err: serde_urlencoded::ser::Error) -> Error {
- Error::EncodeUrl(err)
- }
-}