Always include repo name in exception toasts

This commit is contained in:
Sylvia van Os 2021-01-23 14:21:13 +01:00 committed by Hans-Christoph Steiner
parent e6819e7f12
commit e95e99018a
3 changed files with 15 additions and 15 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}