Skip to content

Commit 9ee15b3

Browse files
authored
feat: return failed to fetch message for invalid registry lookups (#7205)
## Description closes #7186. Before this PR trying to get a non-existing package would result with: ```sh error: Unable to deserialize a github registry lookup response. Body was: "404: Not Found" ``` Now we output: ```sh Failed to fetch {pkg_name} ``` Which is a little bit cleaner in my opinion.
1 parent ac52806 commit 9ee15b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

forc-pkg/src/source/reg/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,9 @@ where
510510
anyhow!(
511511
"Failed to send request to github to obtain package index file from registry {e}"
512512
)
513-
})?;
513+
})?
514+
.error_for_status()
515+
.map_err(|_| anyhow!("Failed to fetch {pkg_name}"))?;
514516

515517
let contents = index_response.text().await?;
516518
let index_file: IndexFile = serde_json::from_str(&contents).with_context(|| {

0 commit comments

Comments
 (0)