error handling
Some checks failed
ci/woodpecker/push/pkgbuild/2 Pipeline is pending
ci/woodpecker/push/pkgbuild/1 Pipeline was successful
ci/woodpecker/push/container Pipeline failed

This commit is contained in:
JMARyA 2025-06-28 04:08:12 +02:00
parent 2544143809
commit 48476d5cf4
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 38 additions and 9 deletions

View file

@ -8,6 +8,7 @@ use rocket::{State, get};
use pacco::pkg::{Repository, arch::Architecture};
use serde_json::json;
use crate::routes::no_such_repo_error;
use crate::routes::ui::arch_card;
use pacco::config::Config;
@ -18,18 +19,18 @@ pub async fn repo_arch_json(
ctx: RequestContext,
arch: &str,
config: &State<Config>,
) -> serde_json::Value {
) -> Result<serde_json::Value, serde_json::Value> {
let arch = Architecture::parse(arch).unwrap_or(Architecture::any);
let repo_name = repo;
let repo = Repository::new(repo_name).unwrap();
let repo = Repository::new(repo_name).ok_or_else(no_such_repo_error)?;
let packages = repo.list_pkg_arch(arch.clone());
json!({
Ok(json!({
"repo": repo_name,
"arch": arch.to_string(),
"packages": packages
})
}))
}
/// Repository Overview UI