Provide better errors when packages aren't found.

This commit is contained in:
KtorZ
2023-01-18 16:34:26 +01:00
parent 6e64bb72e6
commit b475d6a6a4
3 changed files with 11 additions and 4 deletions

View File

@@ -78,13 +78,19 @@ impl<'a> Downloader<'a> {
.get(url)
.header("User-Agent", "aiken-lang")
.send()
.await?
.bytes()
.await?;
if response.status().as_u16() >= 400 {
return Err(Error::UnknownPackageVersion {
package: package.clone(),
});
}
let bytes = response.bytes().await?;
// let PackageSource::Github { url } = &package.source;
tokio::fs::write(&zipball_path, response).await?;
tokio::fs::write(&zipball_path, bytes).await?;
Ok(true)
}