mirror of
https://github.com/esp-rs/espup.git
synced 2025-10-01 06:40:34 +00:00
Return error if GET request fails (#471)
* fix: Return error if get request fails * docs: Update changelog
This commit is contained in:
parent
54b453b172
commit
6251fd2b7f
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Return an error if GET request fails (#471)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@ pub enum Error {
|
|||||||
#[error("Failed to query GitHub API: Invalid Github token")]
|
#[error("Failed to query GitHub API: Invalid Github token")]
|
||||||
GithubTokenInvalid,
|
GithubTokenInvalid,
|
||||||
|
|
||||||
|
#[diagnostic(code(espup::toolchain::http_error))]
|
||||||
|
#[error("HTTP GET Error: {0}")]
|
||||||
|
HttpError(String),
|
||||||
|
|
||||||
#[diagnostic(code(espup::toolchain::rust::install_riscv_target))]
|
#[diagnostic(code(espup::toolchain::rust::install_riscv_target))]
|
||||||
#[error("Failed to Install RISC-V targets for '{0}' toolchain")]
|
#[error("Failed to Install RISC-V targets for '{0}' toolchain")]
|
||||||
InstallRiscvTarget(String),
|
InstallRiscvTarget(String),
|
||||||
|
@ -120,7 +120,11 @@ pub async fn download_file(
|
|||||||
|
|
||||||
let resp = {
|
let resp = {
|
||||||
let client = build_proxy_async_client()?;
|
let client = build_proxy_async_client()?;
|
||||||
client.get(&url).send().await?
|
let resp = client.get(&url).send().await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
return Err(Error::HttpError(resp.status().to_string()));
|
||||||
|
}
|
||||||
|
resp
|
||||||
};
|
};
|
||||||
let bytes = {
|
let bytes = {
|
||||||
let len = resp.content_length();
|
let len = resp.content_length();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user