aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java b/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java
index a0e0a0219..2e376360a 100644
--- a/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java
+++ b/src/main/java/de/pixart/messenger/services/ChannelDiscoveryService.java
@@ -20,6 +20,7 @@ import de.pixart.messenger.http.services.MuclumbusService;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
+import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -81,8 +82,8 @@ public class ChannelDiscoveryService {
public void onResponse(@NonNull Call<MuclumbusService.Rooms> call, @NonNull Response<MuclumbusService.Rooms> response) {
final MuclumbusService.Rooms body = response.body();
if (body == null) {
- Log.d(Config.LOGTAG, "code from muclumbus=" + response.code());
listener.onChannelSearchResultsFound(Collections.emptyList());
+ logError(response);
return;
}
cache.put("", body.items);
@@ -108,8 +109,8 @@ public class ChannelDiscoveryService {
public void onResponse(@NonNull Call<MuclumbusService.SearchResult> call, @NonNull Response<MuclumbusService.SearchResult> response) {
final MuclumbusService.SearchResult body = response.body();
if (body == null) {
- Log.d(Config.LOGTAG, "code from muclumbus=" + response.code());
listener.onChannelSearchResultsFound(Collections.emptyList());
+ logError(response);
return;
}
cache.put(query, body.result.items);
@@ -124,6 +125,19 @@ public class ChannelDiscoveryService {
});
}
+ private static void logError(final Response response) {
+ final ResponseBody errorBody = response.errorBody();
+ Log.d(Config.LOGTAG, "code from muclumbus=" + response.code());
+ if (errorBody == null) {
+ return;
+ }
+ try {
+ Log.d(Config.LOGTAG, "error body=" + errorBody.string());
+ } catch (IOException e) {
+ //ignored
+ }
+ }
+
public interface OnChannelSearchResultsFound {
void onChannelSearchResultsFound(List<MuclumbusService.Room> results);
}