From 1a5e6e90c634baea697d2d62dbac8b9b2dcbc41b Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 6 Dec 2024 19:36:10 -0800 Subject: [PATCH] presumptuously rename error --- validation/api/src/lib.rs | 35 +++++++++++++++++------------------ validation/src/validator.rs | 4 ++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/validation/api/src/lib.rs b/validation/api/src/lib.rs index a9fb26e..d1ec5d3 100644 --- a/validation/api/src/lib.rs +++ b/validation/api/src/lib.rs @@ -1,15 +1,14 @@ #[derive(Debug)] -pub enum GetError{ +pub enum Error{ ParseError(url::ParseError), Reqwest(reqwest::Error), - JSON(serde_json::Error), } -impl std::fmt::Display for GetError{ +impl std::fmt::Display for Error{ fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ write!(f,"{self:?}") } } -impl std::error::Error for GetError{} +impl std::error::Error for Error{} #[derive(serde::Deserialize)] pub struct ScriptID(i64); @@ -88,25 +87,25 @@ impl Context{ self.client.patch(url) .send().await } - pub async fn get_script(&self,config:GetScriptRequest)->Result{ + pub async fn get_script(&self,config:GetScriptRequest)->Result{ let url_raw=format!("{}/scripts/{}",self.base_url,config.ScriptID.0); - let url=reqwest::Url::parse(url_raw.as_str()).map_err(GetError::ParseError)?; + let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?; - self.get(url).await.map_err(GetError::Reqwest)? - .error_for_status().map_err(GetError::Reqwest)? - .json().await.map_err(GetError::Reqwest) + self.get(url).await.map_err(Error::Reqwest)? + .error_for_status().map_err(Error::Reqwest)? + .json().await.map_err(Error::Reqwest) } - pub async fn get_script_policy_from_hash(&self,config:ScriptPolicyHashRequest)->Result{ + pub async fn get_script_policy_from_hash(&self,config:ScriptPolicyHashRequest)->Result{ let url_raw=format!("{}/script-policy/hash/{}",self.base_url,config.hash); - let url=reqwest::Url::parse(url_raw.as_str()).map_err(GetError::ParseError)?; + let url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?; - self.get(url).await.map_err(GetError::Reqwest)? - .error_for_status().map_err(GetError::Reqwest)? - .json().await.map_err(GetError::Reqwest) + self.get(url).await.map_err(Error::Reqwest)? + .error_for_status().map_err(Error::Reqwest)? + .json().await.map_err(Error::Reqwest) } - pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),GetError>{ + pub async fn update_submission_model(&self,config:UpdateSubmissionModelRequest)->Result<(),Error>{ let url_raw=format!("{}/submissions/{}/model",self.base_url,config.ID); - let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(GetError::ParseError)?; + let mut url=reqwest::Url::parse(url_raw.as_str()).map_err(Error::ParseError)?; { url.query_pairs_mut() @@ -114,8 +113,8 @@ impl Context{ .append_pair("ModelVersion",config.ModelVersion.to_string().as_str()); } - self.patch(url).await.map_err(GetError::Reqwest)? - .error_for_status().map_err(GetError::Reqwest)?; + self.patch(url).await.map_err(Error::Reqwest)? + .error_for_status().map_err(Error::Reqwest)?; Ok(()) } diff --git a/validation/src/validator.rs b/validation/src/validator.rs index 155ad04..7d4ddc2 100644 --- a/validation/src/validator.rs +++ b/validation/src/validator.rs @@ -28,8 +28,8 @@ enum ValidateError{ Get(rbx_asset::cookie::GetError), Json(serde_json::Error), ReadDom(ReadDomError), - ApiGetScriptPolicy(api::GetError), - ApiGetScript(api::GetError), + ApiGetScriptPolicy(api::Error), + ApiGetScript(api::Error), WriteDom(rbx_binary::EncodeError), Upload(rbx_asset::cookie::UploadError), Create(rbx_asset::cookie::CreateError),