server: error when get request has a bad response code

This commit is contained in:
Bill Thiede 2025-01-29 17:25:26 -08:00
parent bd2803f81c
commit bc0135106f

View File

@ -301,7 +301,11 @@ impl<'c> Transformer for SlurpContents<'c> {
let body = if let Some(body) = cacher.get(link.as_str()) { let body = if let Some(body) = cacher.get(link.as_str()) {
String::from_utf8_lossy(&body).to_string() String::from_utf8_lossy(&body).to_string()
} else { } else {
let body = reqwest::get(link.as_str()).await?.text().await?; let body = reqwest::get(link.as_str())
.await?
.error_for_status()?
.text()
.await?;
cacher.set(link.as_str(), body.as_bytes()); cacher.set(link.as_str(), body.as_bytes());
body body
}; };