From 4cad06e456d12462795826fc7aa805d17c86dc67 Mon Sep 17 00:00:00 2001 From: zankia Date: Sun, 15 Feb 2026 11:15:11 +0100 Subject: [PATCH] fix: don't try to parse on error --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/atom.rs | 4 +++- src/rss.rs | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a34a69e..02d52f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -962,7 +962,7 @@ dependencies = [ [[package]] name = "rss_library" -version = "0.3.1" +version = "0.3.2" dependencies = [ "atom_syndication", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index e81db2c..bc7d58d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rss_library" -version = "0.3.1" +version = "0.3.2" edition = "2024" [dependencies] diff --git a/src/atom.rs b/src/atom.rs index b66c228..4b4fe8a 100644 --- a/src/atom.rs +++ b/src/atom.rs @@ -2,7 +2,9 @@ use std::error::Error; use atom_syndication::{Entry, Feed}; pub async fn get_content(source: &str) -> Result> { - 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[..])?; Ok(channel) } diff --git a/src/rss.rs b/src/rss.rs index c1cfb79..d56b6b4 100644 --- a/src/rss.rs +++ b/src/rss.rs @@ -2,7 +2,9 @@ use rss::{Channel, Guid, Item}; use std::error::Error; pub async fn get_content(source: &str) -> Result> { - 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[..])?; Ok(channel) }