Make ChorusError Clone

This commit is contained in:
bitfl0wer 2023-09-01 01:17:23 +02:00
parent 42f2f7bfbe
commit 6e136fba83
3 changed files with 5 additions and 5 deletions

View File

@ -19,7 +19,7 @@ impl Instance {
Err(e) => {
return Err(ChorusError::RequestFailed {
url: endpoint_url,
error: e,
error: e.to_string(),
});
}
};

View File

@ -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<T> = std::result::Result<T, ChorusError>;
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.

View File

@ -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(),
})
}
};