mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
util: Improve error message for failing requests to GH. (#3159)
Release notes: - N/A Co-authored-by: Julia Risley <julia@zed.dev>
This commit is contained in:
parent
1ec6638c7f
commit
bc3572f80e
1 changed files with 9 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
use crate::http::HttpClient;
|
use crate::http::HttpClient;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
use futures::AsyncReadExt;
|
use futures::AsyncReadExt;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -46,6 +46,14 @@ pub async fn latest_github_release(
|
||||||
.await
|
.await
|
||||||
.context("error reading latest release")?;
|
.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::<Vec<GithubRelease>>(body.as_slice()) {
|
let releases = match serde_json::from_slice::<Vec<GithubRelease>>(body.as_slice()) {
|
||||||
Ok(releases) => releases,
|
Ok(releases) => releases,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue