mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-21 18:44:19 +00:00
Improve error passing for the STRATZ interface
This commit is contained in:
parent
35372b24bd
commit
ce1e216ece
2 changed files with 6 additions and 5 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue