pkgs: mailnix: Make errors thrown in config::merge more verbose
All checks were successful
Test / tests (push) Successful in 3m29s
All checks were successful
Test / tests (push) Successful in 3m29s
This commit is contained in:
parent
3a9b2c8b59
commit
79b2ec800e
1 changed files with 24 additions and 30 deletions
|
|
@ -153,43 +153,37 @@ impl Config {
|
||||||
pub fn merge<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Box<dyn Error>> {
|
pub fn merge<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Box<dyn Error>> {
|
||||||
let mut other = Config::load(path).unwrap();
|
let mut other = Config::load(path).unwrap();
|
||||||
|
|
||||||
if !self
|
for domain in self.domains.iter() {
|
||||||
.domains
|
if other.domains.contains(domain) {
|
||||||
.iter()
|
|
||||||
.all(|domain| other.domains.contains(domain))
|
|
||||||
{
|
|
||||||
return Err(
|
return Err(
|
||||||
"domains: Duplicate entry during merge detected, aborting..."
|
"domains: Duplicate entry ({domain}) during merge detected, aborting..."
|
||||||
.to_string()
|
.to_string()
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.domains.append(&mut other.domains);
|
self.domains.append(&mut other.domains);
|
||||||
|
|
||||||
if !self
|
for name in self.accounts.keys() {
|
||||||
.accounts
|
if other.accounts.contains_key(name) {
|
||||||
.keys()
|
|
||||||
.all(|name| other.accounts.contains_key(name))
|
|
||||||
{
|
|
||||||
return Err(
|
return Err(
|
||||||
"accounts: Duplicate entry during merge detected, aborting..."
|
"accounts: Duplicate entry ({name}) during merge detected, aborting..."
|
||||||
.to_string()
|
.to_string()
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.accounts.extend(other.accounts);
|
self.accounts.extend(other.accounts);
|
||||||
|
|
||||||
if !self
|
for alias in self.aliases.keys() {
|
||||||
.aliases
|
if other.aliases.contains_key(alias) {
|
||||||
.keys()
|
|
||||||
.all(|alias| other.aliases.contains_key(alias))
|
|
||||||
{
|
|
||||||
return Err(
|
return Err(
|
||||||
"aliases: Duplicate entry during merge detected, aborting..."
|
"aliases: Duplicate entry ({alias}) during merge detected, aborting..."
|
||||||
.to_string()
|
.to_string()
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
self.aliases.extend(other.aliases);
|
self.aliases.extend(other.aliases);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue