]> quire.kejadlen.dev Git - quire.git/commitdiff
Use more accurate error variants in Repo::config()
authorAlpha Chen <alpha@kejadlen.dev>
Sun, 26 Apr 2026 19:05:12 +0000 (12:05 -0700)
committerAlpha Chen <alpha@kejadlen.dev>
Mon, 27 Apr 2026 01:34:36 +0000 (18:34 -0700)
Unexpected git failures now surface as Error::Git rather than
Error::NotFound, and UTF-8 decoding failures use Error::Io with
InvalidData rather than Error::NotFound.

Assisted-by: GLM-5.1 via pi
src/error.rs
src/quire.rs

index 7ec6b81d624bfbd5421e0abc9cda5d51a92b345c..7f4940c10344d61456b95de758af3430ec459af2 100644 (file)
@@ -14,6 +14,9 @@ pub enum Error {
 
     #[error("fennel error: {0}")]
     Fennel(String),
+
+    #[error("git error: {0}")]
+    Git(String),
 }
 
 pub type Result<T> = std::result::Result<T, Error>;
index 0828b55bc6e75074b6d0708226bfc2f9fbe94bc4..fd552d2834bc73836c155e26e7afca8744a339d5 100644 (file)
@@ -71,13 +71,17 @@ impl Repo {
                 return Ok(RepoConfig::default());
             }
             // Unexpected git error.
-            return Err(crate::Error::NotFound(format!(
+            return Err(crate::Error::Git(format!(
                 "failed to read HEAD:.quire/config.fnl: {stderr}"
             )));
         }
 
-        let source = String::from_utf8(output.stdout)
-            .map_err(|e| crate::Error::NotFound(format!("config is not valid UTF-8: {e}")))?;
+        let source = String::from_utf8(output.stdout).map_err(|e| {
+            crate::Error::Io(std::io::Error::new(
+                std::io::ErrorKind::InvalidData,
+                format!("config is not valid UTF-8: {e}"),
+            ))
+        })?;
 
         let fennel = Fennel::new().map_err(|e| crate::Error::Fennel(e.to_string()))?;
         fennel