From 67f8a5964394be89fdcd5dd8b6e109e738ccb575 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 8 Dec 2024 22:57:43 +0900 Subject: [PATCH] config: remove unused ConfigEnvError variant, convert io::Error explicitly It wasn't obvious which io::Error was mapped to a "file creation" error. Perhaps, file creation will be moved to caller, but let's make the error handling explicit so we'll remove the unused error variant later. --- cli/src/config.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cli/src/config.rs b/cli/src/config.rs index 98843a547..34ca699b4 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -53,12 +53,10 @@ pub fn parse_toml_value_or_bare_string(value_str: &str) -> toml_edit::Value { #[derive(Error, Debug)] pub enum ConfigEnvError { - #[error(transparent)] - ConfigReadError(#[from] ConfigError), #[error("Both {0} and {1} exist. Please consolidate your configs in one of them.")] AmbiguousSource(PathBuf, PathBuf), #[error(transparent)] - ConfigCreateError(#[from] std::io::Error), + CreateFile(std::io::Error), } /// Configuration variable with its source information. @@ -255,7 +253,7 @@ impl ConfigEnv { // to create an empty file to be overwritten. Since it's unclear // who and when to update ConfigPath::New(_) to ::Existing(_), // it's probably better to not cache the path existence. - create_config_file(path)?; + create_config_file(path).map_err(ConfigEnvError::CreateFile)?; Ok(Some(path)) } ConfigPath::Unavailable => Ok(None),