From 6e136fba832acb0520be5c72a5b49370be89b115 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Fri, 1 Sep 2023 01:17:23 +0200 Subject: [PATCH] Make ChorusError Clone --- src/api/policies/instance/instance.rs | 2 +- src/errors.rs | 4 ++-- src/ratelimiter.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/policies/instance/instance.rs b/src/api/policies/instance/instance.rs index aa529ad..4de5fd8 100644 --- a/src/api/policies/instance/instance.rs +++ b/src/api/policies/instance/instance.rs @@ -19,7 +19,7 @@ impl Instance { Err(e) => { return Err(ChorusError::RequestFailed { url: endpoint_url, - error: e, + error: e.to_string(), }); } }; diff --git a/src/errors.rs b/src/errors.rs index 642a3ba..11a7632 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,5 @@ //! Contains all the errors that can be returned by the library. use custom_error::custom_error; -use reqwest::Error; use crate::types::WebSocketEvent; @@ -13,11 +12,12 @@ custom_error! { pub type ChorusResult = std::result::Result; custom_error! { + #[derive(Clone)] pub ChorusError /// Server did not respond. NoResponse = "Did not receive a response from the Server.", /// Reqwest returned an Error instead of a Response object. - RequestFailed{url:String, error: Error} = "An error occured while trying to GET from {url}: {error}", + RequestFailed{url:String, error: String} = "An error occured while trying to GET from {url}: {error}", /// Response received, however, it was not of the successful responses type. Used when no other, special case applies. ReceivedErrorCode{error_code: u16, error: String} = "Received the following error code while requesting from the route: {error_code}", /// Used when there is likely something wrong with the instance, the request was directed to. diff --git a/src/ratelimiter.rs b/src/ratelimiter.rs index d20e28a..88d4a02 100644 --- a/src/ratelimiter.rs +++ b/src/ratelimiter.rs @@ -91,7 +91,7 @@ impl ChorusRequest { log::warn!("Request failed: {:?}", error); return Err(ChorusError::RequestFailed { url: error.url().unwrap().to_string(), - error, + error: error.to_string(), }); } }; @@ -359,7 +359,7 @@ impl ChorusRequest { Err(e) => { return Err(ChorusError::RequestFailed { url: url_api.to_string(), - error: e, + error: e.to_string(), }) } };