From d22690ad41e90c5f34c587e75994e865c2395912 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 6 Aug 2025 16:32:48 +0100 Subject: =?UTF-8?q?=E2=9C=A8feat:=20improve=20error=20handling=20for=20mis?= =?UTF-8?q?sing=20apps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/index.rs') diff --git a/src/index.rs b/src/index.rs index 8f2521a..35bfadf 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1,6 +1,6 @@ use tokio::fs; -use crate::{AppImage, Result, index_dir}; +use crate::{AppImage, Error, Result, index_dir}; #[derive(Debug, Default)] pub struct Index {} @@ -11,7 +11,13 @@ impl Index { } pub async fn get(&self, appname: &str) -> Result { let index_file_path = index_dir()?.join(format!("{appname}.json")); - let index_file_content = fs::read_to_string(&index_file_path).await?; + let index_file_content = fs::read_to_string(&index_file_path).await.map_err(|e| { + if e.kind() == std::io::ErrorKind::NotFound { + Error::NotFound(appname.to_string()) + } else { + Error::from(e) + } + })?; let appimage: AppImage = serde_json::from_str(&index_file_content)?; Ok(appimage) -- cgit v1.2.3