From 6f5e99be6fa382ef40ddec3529f7fcf86e0ca0c8 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 22 Nov 2020 13:27:51 +0100 Subject: [PATCH] Handle CheckForNewAppVersion exceptions in one place --- .../schabi/newpipe/CheckForNewAppVersion.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java index b18445ab5..661337b28 100644 --- a/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java +++ b/app/src/main/java/org/schabi/newpipe/CheckForNewAppVersion.java @@ -22,13 +22,11 @@ import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonParser; import com.grack.nanojson.JsonParserException; -import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.ErrorInfo; import org.schabi.newpipe.report.UserAction; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -186,15 +184,7 @@ public final class CheckForNewAppVersion { } // Make a network request to get latest NewPipe data. - try { - return DownloaderImpl.getInstance().get(NEWPIPE_API_URL).responseBody(); - } catch (IOException | ReCaptchaException e) { - // connectivity problems, do not alarm user and fail silently - if (DEBUG) { - Log.w(TAG, Log.getStackTraceString(e)); - } - return null; - } + return DownloaderImpl.getInstance().get(NEWPIPE_API_URL).responseBody(); }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -218,15 +208,14 @@ public final class CheckForNewAppVersion { } catch (final JsonParserException e) { // connectivity problems, do not alarm user and fail silently if (DEBUG) { - Log.w(TAG, Log.getStackTraceString(e)); + Log.w(TAG, "Could not get NewPipe API: invalid json", e); } } }, - throwable -> { + e -> { // connectivity problems, do not alarm user and fail silently if (DEBUG) { - Log.i(TAG, "Could not get NewPipe API: network problem"); - Log.i(TAG, Log.getStackTraceString(throwable)); + Log.w(TAG, "Could not get NewPipe API: network problem", e); } }); }