Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private String getCustomMessage(FirebaseException base) {
String response = getResponse(base);
InstanceIdServiceErrorResponse parsed = safeParse(response);
if (!Strings.isNullOrEmpty(parsed.error)) {
return parsed.error;
return "Error while calling the IID service: " + parsed.error;
}

return base.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ public void testSubscribeError() {
TestResponseInterceptor interceptor = new TestResponseInterceptor();
InstanceIdClient client = initInstanceIdClient(response, interceptor);

String content = "{\"error\": \"ErrorCode\"}";
for (int statusCode : HTTP_ERRORS) {
response.setStatusCode(statusCode).setContent("{\"error\": \"test error\"}");
response.setStatusCode(statusCode).setContent(content);

try {
client.subscribeToTopic("test-topic", ImmutableList.of("id1", "id2"));
fail("No error thrown for HTTP error");
} catch (FirebaseMessagingException error) {
checkExceptionFromHttpResponse(error, statusCode, "test error");
String expectedMessage = "Error while calling the IID service: ErrorCode";
checkExceptionFromHttpResponse(error, statusCode, expectedMessage);
}

checkTopicManagementRequestHeader(interceptor.getLastRequest(), TEST_IID_SUBSCRIBE_URL);
Expand Down Expand Up @@ -247,14 +249,16 @@ public void testUnsubscribeError() {
TestResponseInterceptor interceptor = new TestResponseInterceptor();
InstanceIdClient client = initInstanceIdClient(response, interceptor);

String content = "{\"error\": \"ErrorCode\"}";
for (int statusCode : HTTP_ERRORS) {
response.setStatusCode(statusCode).setContent("{\"error\": \"test error\"}");
response.setStatusCode(statusCode).setContent(content);

try {
client.unsubscribeFromTopic("test-topic", ImmutableList.of("id1", "id2"));
fail("No error thrown for HTTP error");
} catch (FirebaseMessagingException error) {
checkExceptionFromHttpResponse(error, statusCode, "test error");
String expectedMessage = "Error while calling the IID service: ErrorCode";
checkExceptionFromHttpResponse(error, statusCode, expectedMessage);
}

checkTopicManagementRequestHeader(interceptor.getLastRequest(), TEST_IID_UNSUBSCRIBE_URL);
Expand Down