chore: Add more context to schema parsing errors
This commit is contained in:
parent
6a5f54b2fd
commit
c3f0e6712c
1 changed files with 10 additions and 5 deletions
|
|
@ -332,14 +332,19 @@ async fn cache_retrieve(uri: &Uri<String>) -> miette::Result<Value> {
|
|||
|
||||
log::debug!("Retrieving schema from {}", uri.bold().italic());
|
||||
tokio::spawn(async move {
|
||||
reqwest::get(&uri)
|
||||
let response = reqwest::get(&uri)
|
||||
.await
|
||||
.into_diagnostic()
|
||||
.with_context(|| format!("Failed to retrieve schema from {uri}"))?
|
||||
.json()
|
||||
.await
|
||||
.with_context(|| format!("Failed to retrieve schema from {uri}"))?;
|
||||
let raw_output = response.bytes().await.into_diagnostic()?;
|
||||
serde_json::from_slice(&raw_output)
|
||||
.into_diagnostic()
|
||||
.with_context(|| format!("Failed to parse json from {uri}"))
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"Failed to parse json from {uri}, contents:\n{}",
|
||||
String::from_utf8_lossy(&raw_output)
|
||||
)
|
||||
})
|
||||
.inspect(|value| trace!("{}:\n{value}", uri.bold().italic()))
|
||||
})
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue