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) { } catch (InterruptedException e) {
// ignored if canceled, the local database just won't be updated // ignored if canceled, the local database just won't be updated
e.printStackTrace(); e.printStackTrace();
@ -205,7 +205,7 @@ public class IndexUpdater {
InputStream indexInputStream = null; InputStream indexInputStream = null;
try { try {
if (downloadedFile == null || !downloadedFile.exists()) { 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 // 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); long timestamp = repoDetailsToSave.getAsLong(RepoTable.Cols.TIMESTAMP);
if (timestamp < repo.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); + timestamp + " < " + repo.timestamp);
} }
@ -240,7 +240,7 @@ public class IndexUpdater {
assertSigningCertFromXmlCorrect(); assertSigningCertFromXmlCorrect();
commitToDb(); commitToDb();
} catch (SAXException | ParserConfigurationException | IOException e) { } catch (SAXException | ParserConfigurationException | IOException e) {
throw new UpdateException("Error parsing index", e); throw new UpdateException(repo, "Error parsing index", e);
} finally { } finally {
FDroidApp.enableBouncyCastleOnLollipop(); FDroidApp.enableBouncyCastleOnLollipop();
Utils.closeQuietly(indexInputStream); Utils.closeQuietly(indexInputStream);
@ -347,22 +347,22 @@ public class IndexUpdater {
private static final long serialVersionUID = -4492452418826132803L; private static final long serialVersionUID = -4492452418826132803L;
public UpdateException(String message) { public UpdateException(Repo repo, String message) {
super(message); super((repo != null ? repo.name + ": " : "") + message);
} }
public UpdateException(String message, Exception cause) { public UpdateException(Repo repo, String message, Exception cause) {
super(message, cause); super((repo != null ? repo.name + ": " : "") + message, cause);
} }
} }
public static class SigningException extends UpdateException { public static class SigningException extends UpdateException {
public SigningException(String message) { 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) { 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) { if (downloader != null) {
FileUtils.deleteQuietly(downloader.outputFile); 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) { } catch (InterruptedException e2) {
// ignored if canceled, the local database just won't be updated // ignored if canceled, the local database just won't be updated
} }
@ -185,7 +185,7 @@ public class IndexV1Updater extends IndexUpdater {
if (downloader != null) { if (downloader != null) {
FileUtils.deleteQuietly(downloader.outputFile); 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) { } catch (InterruptedException e) {
// ignored if canceled, the local database just won't be updated // 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; long timestamp = (Long) repoMap.get("timestamp") / 1000;
if (repo.timestamp > timestamp) { 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); + timestamp + " < " + repo.timestamp);
} }

View File

@ -106,7 +106,7 @@ public class RepoPersister {
try { try {
context.getContentResolver().applyBatch(TempApkProvider.getAuthority(), apkOperations); context.getContentResolver().applyBatch(TempApkProvider.getAuthority(), apkOperations);
} catch (RemoteException | OperationApplicationException e) { } 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); context.getContentResolver().applyBatch(TempAppProvider.getAuthority(), appOperations);
return getIdsForPackages(appsToSave); return getIdsForPackages(appsToSave);
} catch (RemoteException | OperationApplicationException e) { } 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);
} }
} }