diff options
Diffstat (limited to 'src/zotapi.rs')
-rw-r--r-- | src/zotapi.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/zotapi.rs b/src/zotapi.rs index 5a2f5cc..0a5c317 100644 --- a/src/zotapi.rs +++ b/src/zotapi.rs @@ -14,7 +14,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. -use crate::Channel; +use crate::{ + Channel, + Error, +}; use url::Url; use reqwest::{ self, @@ -73,8 +76,14 @@ impl ZotApi { /** * Return the channel stream as json. */ - pub async fn channel_stream(&self) -> Result<String, Box<dyn std::error::Error>> { - Ok(self.get("channel/stream").send().await?.text().await?) + pub async fn channel_stream(&self) -> Result<String, Error> { + let response = self.get("channel/stream").send().await?; + + if response.status().is_success() { + Ok(response.text().await?) + } else { + Err(response.status().into()) + } } /** |