impl From reqwest::Error for ChorusError

This commit is contained in:
bitfl0wer 2023-12-03 12:49:07 +01:00
parent 5f41f57e77
commit 99155d1e5b
1 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,6 @@
//! Contains all the errors that can be returned by the library. //! Contains all the errors that can be returned by the library.
use custom_error::custom_error; use custom_error::custom_error;
use url::Url;
use crate::types::WebSocketEvent; use crate::types::WebSocketEvent;
@ -44,6 +45,18 @@ custom_error! {
InvalidArguments{error: String} = "Invalid arguments were provided. Error: {error}" InvalidArguments{error: String} = "Invalid arguments were provided. Error: {error}"
} }
impl From<reqwest::Error> for ChorusError {
fn from(value: reqwest::Error) -> Self {
ChorusError::RequestFailed {
url: match value.url() {
Some(url) => url.to_string(),
None => "None".to_string(),
},
error: value.to_string(),
}
}
}
custom_error! { custom_error! {
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub ObserverError pub ObserverError