From e95e99018a9bb20a6d4f87a270f114ff33da1862 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sat, 23 Jan 2021 14:21:13 +0100 Subject: [PATCH] Always include repo name in exception toasts --- .../java/org/fdroid/fdroid/IndexUpdater.java | 20 +++++++++---------- .../org/fdroid/fdroid/IndexV1Updater.java | 6 +++--- .../org/fdroid/fdroid/data/RepoPersister.java | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java b/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java index c10b0ca69..9948b09b0 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexUpdater.java @@ -142,7 +142,7 @@ public class IndexUpdater { } } - throw new UpdateException("Error getting F-Droid index file", e); + throw new UpdateException(repo, "Error getting F-Droid index file", e); } catch (InterruptedException e) { // ignored if canceled, the local database just won't be updated e.printStackTrace(); @@ -205,7 +205,7 @@ public class IndexUpdater { InputStream indexInputStream = null; try { if (downloadedFile == null || !downloadedFile.exists()) { - throw new UpdateException(downloadedFile + " does not exist!"); + throw new UpdateException(repo, downloadedFile + " does not exist!"); } // Due to a bug in Android 5.0 Lollipop, the inclusion of bouncycastle causes @@ -229,7 +229,7 @@ public class IndexUpdater { long timestamp = repoDetailsToSave.getAsLong(RepoTable.Cols.TIMESTAMP); if (timestamp < repo.timestamp) { - throw new UpdateException("index.jar is older that current index! " + throw new UpdateException(repo, "index.jar is older that current index! " + timestamp + " < " + repo.timestamp); } @@ -240,7 +240,7 @@ public class IndexUpdater { assertSigningCertFromXmlCorrect(); commitToDb(); } catch (SAXException | ParserConfigurationException | IOException e) { - throw new UpdateException("Error parsing index", e); + throw new UpdateException(repo, "Error parsing index", e); } finally { FDroidApp.enableBouncyCastleOnLollipop(); Utils.closeQuietly(indexInputStream); @@ -347,22 +347,22 @@ public class IndexUpdater { private static final long serialVersionUID = -4492452418826132803L; - public UpdateException(String message) { - super(message); + public UpdateException(Repo repo, String message) { + super((repo != null ? repo.name + ": " : "") + message); } - public UpdateException(String message, Exception cause) { - super(message, cause); + public UpdateException(Repo repo, String message, Exception cause) { + super((repo != null ? repo.name + ": " : "") + message, cause); } } public static class SigningException extends UpdateException { public SigningException(String message) { - super("Repository was not signed correctly: " + message); + super(null, "Repository was not signed correctly: " + message); } public SigningException(Repo repo, String message) { - super((repo == null ? "Repository" : repo.name) + " was not signed correctly: " + message); + super(repo, "Repository was not signed correctly: " + message); } } diff --git a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java index 1bef52238..6ed2faf17 100644 --- a/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java +++ b/app/src/main/java/org/fdroid/fdroid/IndexV1Updater.java @@ -176,7 +176,7 @@ public class IndexV1Updater extends IndexUpdater { if (downloader != null) { FileUtils.deleteQuietly(downloader.outputFile); } - throw new IndexUpdater.UpdateException("Error getting F-Droid index file", e2); + throw new IndexUpdater.UpdateException(repo, "Error getting F-Droid index file", e2); } catch (InterruptedException e2) { // ignored if canceled, the local database just won't be updated } @@ -185,7 +185,7 @@ public class IndexV1Updater extends IndexUpdater { if (downloader != null) { FileUtils.deleteQuietly(downloader.outputFile); } - throw new IndexUpdater.UpdateException("Error getting F-Droid index file", e); + throw new IndexUpdater.UpdateException(repo, "Error getting F-Droid index file", e); } catch (InterruptedException e) { // ignored if canceled, the local database just won't be updated } @@ -278,7 +278,7 @@ public class IndexV1Updater extends IndexUpdater { long timestamp = (Long) repoMap.get("timestamp") / 1000; if (repo.timestamp > timestamp) { - throw new IndexUpdater.UpdateException("index.jar is older that current index! " + throw new IndexUpdater.UpdateException(repo, "index.jar is older that current index! " + timestamp + " < " + repo.timestamp); } diff --git a/app/src/main/java/org/fdroid/fdroid/data/RepoPersister.java b/app/src/main/java/org/fdroid/fdroid/data/RepoPersister.java index a7a367346..285bb56ba 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/RepoPersister.java +++ b/app/src/main/java/org/fdroid/fdroid/data/RepoPersister.java @@ -106,7 +106,7 @@ public class RepoPersister { try { context.getContentResolver().applyBatch(TempApkProvider.getAuthority(), apkOperations); } catch (RemoteException | OperationApplicationException e) { - throw new IndexUpdater.UpdateException("An internal error occurred while updating the database", e); + throw new IndexUpdater.UpdateException(repo, "An internal error occurred while updating the database", e); } } @@ -122,7 +122,7 @@ public class RepoPersister { context.getContentResolver().applyBatch(TempAppProvider.getAuthority(), appOperations); return getIdsForPackages(appsToSave); } catch (RemoteException | OperationApplicationException e) { - throw new IndexUpdater.UpdateException("An internal error occurred while updating the database", e); + throw new IndexUpdater.UpdateException(repo, "An internal error occurred while updating the database", e); } }