Improve error messages when fetching single GitHub release (#9219)

Release Notes:

- N/A
This commit is contained in:
Thorsten Ball 2024-03-12 14:12:44 +01:00 committed by GitHub
parent e103607134
commit 9f396948bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,14 +85,19 @@ pub async fn github_release_with_tag(
let mut response = http
.get(&url, Default::default(), true)
.await
.context("error fetching latest release")?;
.with_context(|| format!("error fetching release {} of {}", tag, repo_name_with_owner))?;
let mut body = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.context("error reading latest release")?;
.with_context(|| {
format!(
"error reading response body for release {} of {}",
tag, repo_name_with_owner
)
})?;
if response.status().is_client_error() {
let text = String::from_utf8_lossy(body.as_slice());
@ -111,7 +116,11 @@ pub async fn github_release_with_tag(
"GitHub API response text: {:?}",
String::from_utf8_lossy(body.as_slice())
);
return Err(anyhow!("error deserializing latest release"));
Err(anyhow!(
"error deserializing release {} of {}",
tag,
repo_name_with_owner
))
}
}
}