From 987d6df4c858b52122015fe5288679447715136e Mon Sep 17 00:00:00 2001 From: Matthias Puchstein Date: Thu, 27 Mar 2025 04:57:18 +0100 Subject: [PATCH] added some errors to querying general --- crates/alhp_api/src/lib.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/alhp_api/src/lib.rs b/crates/alhp_api/src/lib.rs index 4e0eccb..43d21c1 100644 --- a/crates/alhp_api/src/lib.rs +++ b/crates/alhp_api/src/lib.rs @@ -151,6 +151,7 @@ pub mod general { use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use std::error::Error; + use std::io::ErrorKind; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LtoStats { @@ -189,14 +190,18 @@ pub mod general { } } 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_GENERAL_EXT,); - 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" + ))) } } }