From dc7405474eb77750d76f5febe0644299258b4c2e Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 12 Feb 2024 10:45:38 -0300 Subject: [PATCH] Improve error reporting when reading snapshot version --- .../main/java/org/calyxos/backup/storage/restore/Restore.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt index 1fc0e3e2..16776135 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt @@ -154,13 +154,13 @@ internal class Restore( @Throws(IOException::class, GeneralSecurityException::class) internal fun InputStream.readVersion(expectedVersion: Int? = null): Int { val version = read() - if (version == -1) throw IOException() + if (version == -1) throw IOException("File empty!") if (expectedVersion != null && version != expectedVersion) { throw GeneralSecurityException("Expected version $expectedVersion, not $version") } if (version > Backup.VERSION) { // TODO maybe throw a different exception here and tell the user? - throw IOException() + throw IOException("Got version $version which is higher than what is supported.") } return version }