mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Attach information to ContactExistsException.
This commit is contained in:
@@ -229,7 +229,7 @@ class ContactExchangeManagerImpl implements ContactExchangeManager {
|
||||
logException(LOG, WARNING, e);
|
||||
tryToClose(conn);
|
||||
eventBus.broadcast(
|
||||
new ContactExchangeFailedEvent(remoteInfo.author));
|
||||
new ContactExchangeFailedEvent(e.getRemoteAuthor()));
|
||||
} catch (DbException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
tryToClose(conn);
|
||||
|
||||
@@ -234,16 +234,15 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
|
||||
@Override
|
||||
public ContactId addContact(Transaction transaction, Author remote,
|
||||
AuthorId local, boolean verified)
|
||||
throws DbException {
|
||||
AuthorId local, boolean verified) throws DbException {
|
||||
if (transaction.isReadOnly()) throw new IllegalArgumentException();
|
||||
T txn = unbox(transaction);
|
||||
if (!db.containsIdentity(txn, local))
|
||||
throw new NoSuchIdentityException();
|
||||
if (db.containsIdentity(txn, remote.getId()))
|
||||
throw new ContactExistsException();
|
||||
throw new ContactExistsException(local, remote);
|
||||
if (db.containsContact(txn, remote.getId(), local))
|
||||
throw new ContactExistsException();
|
||||
throw new ContactExistsException(local, remote);
|
||||
ContactId c = db.addContact(txn, remote, local, verified);
|
||||
transaction.attach(new ContactAddedEvent(c));
|
||||
return c;
|
||||
|
||||
@@ -1459,7 +1459,8 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
|
||||
true));
|
||||
fail();
|
||||
} catch (ContactExistsException expected) {
|
||||
// Expected
|
||||
assertEquals(localAuthor.getId(), expected.getLocalAuthorId());
|
||||
assertEquals(author, expected.getRemoteAuthor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,7 +1489,8 @@ public class DatabaseComponentImplTest extends BrambleMockTestCase {
|
||||
true));
|
||||
fail();
|
||||
} catch (ContactExistsException expected) {
|
||||
// Expected
|
||||
assertEquals(localAuthor.getId(), expected.getLocalAuthorId());
|
||||
assertEquals(author, expected.getRemoteAuthor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user