AccountManager: Include ID key in exception message when already in use

Change-Id: I786bf49c74b36bd314dfff81f86a3df09c341489
This commit is contained in:
David Pursehouse
2017-09-04 08:52:51 +09:00
parent 8c266c1acc
commit 1840193c1d
2 changed files with 5 additions and 3 deletions

View File

@@ -580,10 +580,11 @@ public class AccountIT extends AbstractDaemonTest {
@Test
public void cannotAddEmailAddressUsedByAnotherAccount() throws Exception {
EmailInput input = newEmailInput("new.email@example.com");
String email = "new.email@example.com";
EmailInput input = newEmailInput(email);
gApi.accounts().self().addEmail(input);
exception.expect(ResourceConflictException.class);
exception.expectMessage("in use by another account");
exception.expectMessage("Identity 'mailto:" + email + "' in use by another account");
gApi.accounts().id(user.username).addEmail(input);
}

View File

@@ -345,7 +345,8 @@ public class AccountManager {
ExternalId extId = externalIds.get(who.getExternalIdKey());
if (extId != null) {
if (!extId.accountId().equals(to)) {
throw new AccountException("Identity in use by another account");
throw new AccountException(
"Identity '" + extId.key().get() + "' in use by another account");
}
update(who, extId);
} else {