From a3cdd0e5434d0ba9e9c76b6eceee82141ac5242d Mon Sep 17 00:00:00 2001 From: Matthias Puchstein Date: Thu, 27 Mar 2025 04:56:07 +0100 Subject: [PATCH] added some errors to querying packages --- crates/alhp_api/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/alhp_api/src/lib.rs b/crates/alhp_api/src/lib.rs index 72ef41e..4e0eccb 100644 --- a/crates/alhp_api/src/lib.rs +++ b/crates/alhp_api/src/lib.rs @@ -9,6 +9,7 @@ pub mod packages { use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt; + use std::io::ErrorKind; #[derive(Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq)] #[serde(rename_all = "lowercase")] @@ -126,19 +127,18 @@ pub mod packages { }) } StatusCode::INTERNAL_SERVER_ERROR => { - panic!("Internal Server Error"); + error!("Internal server error"); + Err(Box::new(std::io::Error::new( + ErrorKind::ConnectionAborted, + "Internal server error", + ))) } _ => { - let query_url = format!( - "{}{}{}", - API_BASE_URL, - API_PACKAGES_EXT, - self.query_string() - ); - panic!( - "Unexpected server response: {:?} for query url: {}", - response, query_url - ); + error!("Unexpected status: {}", response.status()); + Err(Box::new(std::io::Error::new( + ErrorKind::Unsupported, + "Unexpected server response" + ))) } } }