added some errors to querying packages

This commit is contained in:
2025-03-27 04:56:07 +01:00
parent cb905667f7
commit a3cdd0e543

View File

@@ -9,6 +9,7 @@ pub mod packages {
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
use std::io::ErrorKind;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq)] #[derive(Debug, Clone, Copy, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
@@ -126,19 +127,18 @@ pub mod packages {
}) })
} }
StatusCode::INTERNAL_SERVER_ERROR => { 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!( error!("Unexpected status: {}", response.status());
"{}{}{}", Err(Box::new(std::io::Error::new(
API_BASE_URL, ErrorKind::Unsupported,
API_PACKAGES_EXT, "Unexpected server response"
self.query_string() )))
);
panic!(
"Unexpected server response: {:?} for query url: {}",
response, query_url
);
} }
} }
} }