1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 20:14:19 +00:00

Improve error passing for the STRATZ interface

This commit is contained in:
Steffo 2024-10-28 05:00:17 +01:00
parent 35372b24bd
commit ce1e216ece
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 6 additions and 5 deletions

View file

@ -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::<QueryResponse>()
.await
.map_err(|_| Error::Parsing)?;
.map_err(Error::Parsing)?;
Ok(response)
}

View file

@ -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;