fix(load_website): return error for status codes

This commit is contained in:
Sam Denty 2022-12-23 21:18:25 +00:00
parent bed4ab8825
commit 4e1710539c
No known key found for this signature in database
GPG key ID: 7B4EAF7B9E291B79
3 changed files with 10 additions and 3 deletions

2
Cargo.lock generated
View file

@ -1525,7 +1525,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "site_icons"
version = "0.3.8"
version = "0.3.9"
dependencies = [
"byteorder",
"clap",

View file

@ -1,6 +1,6 @@
[package]
name = "site_icons"
version = "0.3.8"
version = "0.3.9"
authors = ["Sam Denty <sam@samdenty.com>"]
edition = "2018"
license = "GPL-3.0"

View file

@ -107,8 +107,15 @@ impl Icons {
}
pub async fn load_website<U: IntoUrl>(&mut self, url: U) -> Result<(), Box<dyn Error>> {
let res = CLIENT.get(url).header(ACCEPT, "text/html").send().await?;
let res = CLIENT
.get(url)
.header(ACCEPT, "text/html")
.send()
.await?
.error_for_status()?;
let url = res.url().clone();
let mut body = res.bytes_stream();
let mut parser = driver::parse_document(Html::new_document(), Default::default());