diff options
author | Pietro Albini <pietro@pietroalbini.org> | 2019-03-03 21:41:32 +0100 |
---|---|---|
committer | Pietro Albini <pietro@pietroalbini.org> | 2019-03-08 10:47:20 +0100 |
commit | bfea2ee79db0030db31c4f89d3f9e4f9487bc57d (patch) | |
tree | a16c3356526b0a031781f2b2582c94f4800b7177 /src | |
parent | 67f444d65682a5846a39e499c590c31671270dc2 (diff) |
validate: avoid crashing if a member doesn't exist
Diffstat (limited to 'src')
-rw-r--r-- | src/validate.rs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/validate.rs b/src/validate.rs index cce801f..93a87ac 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -136,12 +136,13 @@ fn validate_list_email_addresses(data: &Data, errors: &mut Vec<String>) { return Ok(()); } wrapper(team.members(data)?.iter(), errors, |member, _| { - let member = data.person(member).unwrap(); - if let Email::Missing = member.email() { - bail!( - "person `{}` is a member of a mailing list but has no email address", - member.github() - ); + if let Some(member) = data.person(member) { + if let Email::Missing = member.email() { + bail!( + "person `{}` is a member of a mailing list but has no email address", + member.github() + ); + } } Ok(()) }); @@ -240,16 +241,17 @@ fn validate_discord_name(data: &Data, errors: &mut Vec<String>) { fn validate_duplicate_permissions(data: &Data, errors: &mut Vec<String>) { wrapper(data.teams(), errors, |team, errors| { wrapper(team.members(&data)?.iter(), errors, |member, _| { - let person = data.person(member).unwrap(); - for permission in Permissions::AVAILABLE { - if team.permissions().has(permission) && person.permissions().has(permission) { - bail!( - "user `{}` has the permission `{}` both explicitly and through \ - the `{}` team", - member, - permission, - team.name() - ); + if let Some(person) = data.person(member) { + for permission in Permissions::AVAILABLE { + if team.permissions().has(permission) && person.permissions().has(permission) { + bail!( + "user `{}` has the permission `{}` both explicitly and through \ + the `{}` team", + member, + permission, + team.name() + ); + } } } Ok(()) |