mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-22 02:54:21 +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)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
use graphql_client::GraphQLQuery;
|
use graphql_client::GraphQLQuery;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
|
|
||||||
|
@ -46,10 +47,10 @@ pub async fn query(client: &reqwest::Client, url: Url, guild_id: i64) -> QueryRe
|
||||||
.json(&body)
|
.json(&body)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::Requesting)?
|
.map_err(Error::Requesting)?
|
||||||
.json::<QueryResponse>()
|
.json::<QueryResponse>()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| Error::Parsing)?;
|
.map_err(Error::Parsing)?;
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ pub type Short = i16;
|
||||||
pub type Long = i64;
|
pub type Long = i64;
|
||||||
pub type Byte = u8;
|
pub type Byte = u8;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum QueryError {
|
pub enum QueryError {
|
||||||
#[error("GraphQL request failed")]
|
#[error("GraphQL request failed")]
|
||||||
Requesting,
|
Requesting(reqwest::Error),
|
||||||
#[error("GraphQL response parsing failed")]
|
#[error("GraphQL response parsing failed")]
|
||||||
Parsing,
|
Parsing(reqwest::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod guild_matches;
|
pub mod guild_matches;
|
||||||
|
|
Loading…
Reference in a new issue