fix: error_for_status

This commit is contained in:
Sam Denty 2023-01-03 16:15:07 +00:00
parent 0dc5df6ccb
commit 4b634e8c3b
No known key found for this signature in database
GPG key ID: 7B4EAF7B9E291B79
2 changed files with 9 additions and 1 deletions

View file

@ -125,7 +125,13 @@ impl IconInfo {
};
}
let res = CLIENT.get(url).headers(headers).send().await?;
let res = CLIENT
.get(url)
.headers(headers)
.send()
.await?
.error_for_status()?;
if !res.status().is_success() {
return Err("failed to fetch".into());
};

View file

@ -34,6 +34,8 @@ async fn load_manifest_cached(url: Url) -> Result<Vec<Icon>, String> {
.send()
.await
.map_err(|e| format!("{}: {:?}", url, e))?
.error_for_status()
.map_err(|e| format!("{}: {:?}", url, e))?
.json()
.await
.map_err(|e| format!("{}: {:?}", url, e))?;