start reworking config loading (for transition) WIP
This commit is contained in:
@@ -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:?}");
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user