Skip to content

Commit

Permalink
Improve error reporting when reading snapshot version
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Feb 12, 2024
1 parent bc09248 commit 704fc42
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 704fc42

Please sign in to comment.