Gelato error information (#1199)
* Display gelato response when failing to parse response * Fix clippy err0.5.2
parent
b4d06f9639
commit
ad1340e094
@ -1,5 +1,21 @@ |
||||
use eyre::eyre; |
||||
use reqwest::Response; |
||||
use serde::de::DeserializeOwned; |
||||
|
||||
const RELAY_URL: &str = "https://relay.gelato.digital"; |
||||
|
||||
pub mod sponsored_call; |
||||
pub mod task_status; |
||||
pub mod types; |
||||
|
||||
async fn parse_response<T: DeserializeOwned>(resp: Response) -> eyre::Result<T> { |
||||
let resp_bytes = resp.bytes().await?; |
||||
match serde_json::from_slice(&resp_bytes) { |
||||
Ok(v) => Ok(v), |
||||
Err(e) => { |
||||
let text = |
||||
String::from_utf8(resp_bytes.into()).unwrap_or_else(|_| "<NOT TEXT>".to_owned()); |
||||
Err(eyre!("{}; {}", e, text)) |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue