diff --git a/src/errors.rs b/src/errors.rs index 4099a6b..7494433 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,5 +1,6 @@ //! Contains all the errors that can be returned by the library. use custom_error::custom_error; +use url::Url; use crate::types::WebSocketEvent; @@ -44,6 +45,18 @@ custom_error! { InvalidArguments{error: String} = "Invalid arguments were provided. Error: {error}" } +impl From 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! { #[derive(PartialEq, Eq)] pub ObserverError