Skip to content

Commit

Permalink
Improve error message when querying FlakeHub fails
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Oct 17, 2023
1 parent 8c97991 commit 612a065
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/cli/cmd/add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ pub(crate) async fn get_flakehub_project_and_url(

let res = client.get(&flakehub_json_url.to_string()).send().await?;

if res.status().is_success() {
let res = res.json::<ProjectCanonicalNames>().await?;
if let Err(e) = res.error_for_status_ref() {
let err_text = res.text().await?;
return Err(e).wrap_err(err_text)?;
};

Ok((res.project, res.pretty_download_url))
} else {
Err(color_eyre::eyre::eyre!(res.text().await?))
}
let res = res.json::<ProjectCanonicalNames>().await?;

Ok((res.project, res.pretty_download_url))
}

0 comments on commit 612a065

Please sign in to comment.