start reworking config loading (for transition) WIP

This commit is contained in:
steven-omaha
2023-02-23 12:09:09 +01:00
parent 5f85394f62
commit 100ee9bef9
3 changed files with 22 additions and 8 deletions
+1 -5
View File
@@ -29,11 +29,7 @@ impl Config {
Ok(content) => content,
Err(e) => {
if e.kind() == ErrorKind::NotFound {
println!(
"creating default config under {}",
config_file.to_string_lossy()
);
return Self::use_default_and_save_to(config_file);
bail!(crate::Error::ConfigFileNotFound)
}
bail!("unexpected error occured: {e:?}");
}
+3
View File
@@ -7,12 +7,15 @@ use std::fmt::Display;
pub enum Error {
/// Package search yields no results.
NoPackagesFound,
/// Config file not found.
ConfigFileNotFound,
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NoPackagesFound => f.write_str("no packages matching query"),
Self::ConfigFileNotFound => f.write_str("config file not found"),
}
}
}