fix: don't try to parse on error

This commit is contained in:
2026-02-15 11:15:11 +01:00
parent 36ddfd40b5
commit 4cad06e456
4 changed files with 8 additions and 4 deletions
Generated
+1 -1
View File
@@ -962,7 +962,7 @@ dependencies = [
[[package]] [[package]]
name = "rss_library" name = "rss_library"
version = "0.3.1" version = "0.3.2"
dependencies = [ dependencies = [
"atom_syndication", "atom_syndication",
"reqwest", "reqwest",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "rss_library" name = "rss_library"
version = "0.3.1" version = "0.3.2"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
+3 -1
View File
@@ -2,7 +2,9 @@ use std::error::Error;
use atom_syndication::{Entry, Feed}; use atom_syndication::{Entry, Feed};
pub async fn get_content(source: &str) -> Result<Feed, Box<dyn Error>> { pub async fn get_content(source: &str) -> Result<Feed, Box<dyn Error>> {
let content = reqwest::get(source).await?.bytes().await?; let content = reqwest::get(source).await?;
content.error_for_status_ref()?;
let content = content.bytes().await?;
let channel = Feed::read_from(&content[..])?; let channel = Feed::read_from(&content[..])?;
Ok(channel) Ok(channel)
} }
+3 -1
View File
@@ -2,7 +2,9 @@ use rss::{Channel, Guid, Item};
use std::error::Error; use std::error::Error;
pub async fn get_content(source: &str) -> Result<Channel, Box<dyn Error>> { pub async fn get_content(source: &str) -> Result<Channel, Box<dyn Error>> {
let content = reqwest::get(source).await?.bytes().await?; let content = reqwest::get(source).await?;
content.error_for_status_ref()?;
let content = content.bytes().await?;
let channel = Channel::read_from(&content[..])?; let channel = Channel::read_from(&content[..])?;
Ok(channel) Ok(channel)
} }