Skip to content

Commit

Permalink
config: remove unused ConfigEnvError variant, convert io::Error expli…
Browse files Browse the repository at this point in the history
…citly

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.
  • Loading branch information
yuja committed Dec 10, 2024
1 parent fc04cdb commit e812a18
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit e812a18

Please sign in to comment.