Throw ApiException when adding contact is not successful

This commit is contained in:
Torsten Grote
2022-01-07 10:22:22 -03:00
parent e52c5ddc8e
commit f400cf5aa0
2 changed files with 2 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ class MailboxApiImpl implements MailboxApi {
OkHttpClient client = httpClientProvider.get();
Response response = client.newCall(request).execute();
if (response.code() == 409) throw new TolerableFailureException();
if (!response.isSuccessful()) throw new IOException();
if (!response.isSuccessful()) throw new ApiException();
}
private Request.Builder getRequestBuilder(String token) {

View File

@@ -9,8 +9,6 @@ import org.briarproject.bramble.mailbox.MailboxApi.TolerableFailureException;
import org.briarproject.bramble.test.BrambleTestCase;
import org.junit.Test;
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.net.SocketFactory;
@@ -200,7 +198,7 @@ public class MailboxApiTest extends BrambleTestCase {
assertEquals(expected, request1.getBody().readUtf8());
// request is not successful
assertThrows(IOException.class, () ->
assertThrows(ApiException.class, () ->
api.addContact(properties, mailboxContact));
RecordedRequest request2 = server.takeRequest();
assertEquals("/contacts", request2.getPath());