From bc3572f80e88105619edbfede449f799478f2592 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:39:45 +0200 Subject: [PATCH] util: Improve error message for failing requests to GH. (#3159) Release notes: - N/A Co-authored-by: Julia Risley --- crates/util/src/github.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/util/src/github.rs b/crates/util/src/github.rs index a3df4c996b..e4b316e12d 100644 --- a/crates/util/src/github.rs +++ b/crates/util/src/github.rs @@ -1,5 +1,5 @@ use crate::http::HttpClient; -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, bail, Context, Result}; use futures::AsyncReadExt; use serde::Deserialize; use std::sync::Arc; @@ -46,6 +46,14 @@ pub async fn latest_github_release( .await .context("error reading latest release")?; + if response.status().is_client_error() { + let text = String::from_utf8_lossy(body.as_slice()); + bail!( + "status error {}, response: {text:?}", + response.status().as_u16() + ); + } + let releases = match serde_json::from_slice::>(body.as_slice()) { Ok(releases) => releases,