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 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"
)))
}
}
}