From 89519b4c5ce4839a362ab9ec9c6359f3c6aa844b Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Mon, 22 Feb 2021 20:42:28 -0500 Subject: add actix backend --- ipfs-api-backend-actix/src/error.rs | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ipfs-api-backend-actix/src/error.rs (limited to 'ipfs-api-backend-actix/src/error.rs') diff --git a/ipfs-api-backend-actix/src/error.rs b/ipfs-api-backend-actix/src/error.rs new file mode 100644 index 0000000..4cd9a25 --- /dev/null +++ b/ipfs-api-backend-actix/src/error.rs @@ -0,0 +1,46 @@ +// Copyright 2017 rust-ipfs-api Developers +// +// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. +// + +use std::string::FromUtf8Error; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum Error { + #[error("api returned error `{0}`")] + Api(ipfs_api_prelude::ApiError), + + #[error("actix client payload error `{0}`")] + ClientPayload(#[from] awc::error::PayloadError), + + #[error("actix client send request error `{0}`")] + ClientSend(#[from] awc::error::SendRequestError), + + #[error("http error `{0}`")] + Http(#[from] http::Error), + + #[error("json parse error `{0}`")] + Parse(#[from] serde_json::Error), + + #[error("utf8 decoding error `{0}`")] + ParseUtf8(#[from] FromUtf8Error), + + #[error("uri error `{0}`")] + Url(#[from] http::uri::InvalidUri), + + #[error("url encoding error `{0}`")] + EncodeUrl(#[from] serde_urlencoded::ser::Error), + + #[error("ipfs client error `{0}`")] + IpfsClientError(#[from] ipfs_api_prelude::Error), +} + +impl From for Error { + fn from(err: ipfs_api_prelude::ApiError) -> Self { + Error::Api(err) + } +} -- cgit v1.2.3 From 4ede307efb87bad2627190665279123e588a3494 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Mon, 22 Feb 2021 22:56:04 -0500 Subject: centralize errors in prelude as much as possible --- ipfs-api-backend-actix/src/error.rs | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'ipfs-api-backend-actix/src/error.rs') diff --git a/ipfs-api-backend-actix/src/error.rs b/ipfs-api-backend-actix/src/error.rs index 4cd9a25..aad2b05 100644 --- a/ipfs-api-backend-actix/src/error.rs +++ b/ipfs-api-backend-actix/src/error.rs @@ -6,7 +6,6 @@ // copied, modified, or distributed except according to those terms. // -use std::string::FromUtf8Error; use thiserror::Error; #[derive(Debug, Error)] @@ -23,18 +22,6 @@ pub enum Error { #[error("http error `{0}`")] Http(#[from] http::Error), - #[error("json parse error `{0}`")] - Parse(#[from] serde_json::Error), - - #[error("utf8 decoding error `{0}`")] - ParseUtf8(#[from] FromUtf8Error), - - #[error("uri error `{0}`")] - Url(#[from] http::uri::InvalidUri), - - #[error("url encoding error `{0}`")] - EncodeUrl(#[from] serde_urlencoded::ser::Error), - #[error("ipfs client error `{0}`")] IpfsClientError(#[from] ipfs_api_prelude::Error), } -- cgit v1.2.3 From fc3cd21efe52b0575617bcd249b30e8846ad2278 Mon Sep 17 00:00:00 2001 From: Ferris Tseng Date: Tue, 23 Feb 2021 23:50:30 -0500 Subject: update copyright headers --- ipfs-api-backend-actix/src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ipfs-api-backend-actix/src/error.rs') diff --git a/ipfs-api-backend-actix/src/error.rs b/ipfs-api-backend-actix/src/error.rs index aad2b05..99af54d 100644 --- a/ipfs-api-backend-actix/src/error.rs +++ b/ipfs-api-backend-actix/src/error.rs @@ -1,4 +1,4 @@ -// Copyright 2017 rust-ipfs-api Developers +// Copyright 2021 rust-ipfs-api Developers // // Licensed under the Apache License, Version 2.0, or the MIT license