clean up error contexts

This commit is contained in:
steven-omaha
2023-02-15 16:15:54 +01:00
parent 93075c4bfc
commit ab87194850
2 changed files with 5 additions and 4 deletions
+4 -2
View File
@@ -47,10 +47,12 @@ fn main_inner() -> Result<()> {
let args = get_args(); let args = get_args();
let config_file = get_config_path().context("getting config file")?; let config_file = get_config_path().context("getting config file")?;
let config = Config::load(&config_file).context("loading config file")?; let config = Config::load(&config_file)
.with_context(|| format!("loading config file {}", config_file.to_string_lossy()))?;
let group_dir = get_group_dir().context("resolving group dir")?; let group_dir = get_group_dir().context("resolving group dir")?;
let groups = Group::load(&group_dir, config.warn_not_symlinks).context("loading groups")?; let groups = Group::load(&group_dir, config.warn_not_symlinks)
.with_context(|| format!("loading groups under {}", group_dir.to_string_lossy()))?;
let pacdef = Pacdef::new(args, config, groups); let pacdef = Pacdef::new(args, config, groups);
pacdef.run_action_from_arg().context("running action") pacdef.run_action_from_arg().context("running action")
+1 -2
View File
@@ -36,8 +36,7 @@ impl Group {
if !group_dir.is_dir() { if !group_dir.is_dir() {
// we only need to create the innermost dir. The rest was already created from when // we only need to create the innermost dir. The rest was already created from when
// we loaded the config // we loaded the config
create_dir(group_dir) create_dir(group_dir).context("group dir does not exist, creating")?;
.with_context(|| format!("creating group dir {}", group_dir.to_string_lossy()))?;
} }
for entry in group_dir.read_dir().context("reading group dir")? { for entry in group_dir.read_dir().context("reading group dir")? {