From 99155d1e5b46c00f1c38aa29494b44afb13e00a1 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 3 Dec 2023 12:49:07 +0100 Subject: [PATCH] impl From reqwest::Error for ChorusError --- src/errors.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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