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,42 +153,36 @@ impl Config {
|
|||
pub fn merge<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Box<dyn Error>> {
|
||||
let mut other = Config::load(path).unwrap();
|
||||
|
||||
if !self
|
||||
.domains
|
||||
.iter()
|
||||
.all(|domain| other.domains.contains(domain))
|
||||
{
|
||||
return Err(
|
||||
"domains: Duplicate entry during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
for domain in self.domains.iter() {
|
||||
if other.domains.contains(domain) {
|
||||
return Err(
|
||||
"domains: Duplicate entry ({domain}) during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.domains.append(&mut other.domains);
|
||||
|
||||
if !self
|
||||
.accounts
|
||||
.keys()
|
||||
.all(|name| other.accounts.contains_key(name))
|
||||
{
|
||||
return Err(
|
||||
"accounts: Duplicate entry during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
for name in self.accounts.keys() {
|
||||
if other.accounts.contains_key(name) {
|
||||
return Err(
|
||||
"accounts: Duplicate entry ({name}) during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.accounts.extend(other.accounts);
|
||||
|
||||
if !self
|
||||
.aliases
|
||||
.keys()
|
||||
.all(|alias| other.aliases.contains_key(alias))
|
||||
{
|
||||
return Err(
|
||||
"aliases: Duplicate entry during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
for alias in self.aliases.keys() {
|
||||
if other.aliases.contains_key(alias) {
|
||||
return Err(
|
||||
"aliases: Duplicate entry ({alias}) during merge detected, aborting..."
|
||||
.to_string()
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
self.aliases.extend(other.aliases);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue