From badaf852659ae6a34785db7ec3e7a969a7456d3c Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sun, 26 Apr 2026 12:05:12 -0700 Subject: [PATCH] Use more accurate error variants in Repo::config() 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 | 3 +++ src/quire.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/error.rs b/src/error.rs index 7ec6b81..7f4940c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -14,6 +14,9 @@ pub enum Error { #[error("fennel error: {0}")] Fennel(String), + + #[error("git error: {0}")] + Git(String), } pub type Result = std::result::Result; diff --git a/src/quire.rs b/src/quire.rs index 0828b55..fd552d2 100644 --- a/src/quire.rs +++ b/src/quire.rs @@ -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 -- 2.54.0