From ce1e216ece2a2c056d17f032d20b7c0373478305 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 28 Oct 2024 05:00:17 +0100 Subject: [PATCH] Improve error passing for the STRATZ interface --- src/interfaces/stratz/guild_matches.rs | 5 +++-- src/interfaces/stratz/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/interfaces/stratz/guild_matches.rs b/src/interfaces/stratz/guild_matches.rs index e4155ecd..1bbc4cdf 100644 --- a/src/interfaces/stratz/guild_matches.rs +++ b/src/interfaces/stratz/guild_matches.rs @@ -1,5 +1,6 @@ #![allow(unused_imports)] +use anyhow::Context; use graphql_client::GraphQLQuery; use reqwest::Url; @@ -46,10 +47,10 @@ pub async fn query(client: &reqwest::Client, url: Url, guild_id: i64) -> QueryRe .json(&body) .send() .await - .map_err(|_| Error::Requesting)? + .map_err(Error::Requesting)? .json::() .await - .map_err(|_| Error::Parsing)?; + .map_err(Error::Parsing)?; Ok(response) } diff --git a/src/interfaces/stratz/mod.rs b/src/interfaces/stratz/mod.rs index b804445a..3d1f83c6 100644 --- a/src/interfaces/stratz/mod.rs +++ b/src/interfaces/stratz/mod.rs @@ -4,12 +4,12 @@ pub type Short = i16; pub type Long = i64; pub type Byte = u8; -#[derive(Debug, Clone, Error)] +#[derive(Debug, Error)] pub enum QueryError { #[error("GraphQL request failed")] - Requesting, + Requesting(reqwest::Error), #[error("GraphQL response parsing failed")] - Parsing, + Parsing(reqwest::Error), } pub mod guild_matches;