Improve error reporting when reading snapshot version
This commit is contained in:
parent
fd90be8776
commit
dc7405474e
1 changed files with 2 additions and 2 deletions
|
@ -154,13 +154,13 @@ internal class Restore(
|
||||||
@Throws(IOException::class, GeneralSecurityException::class)
|
@Throws(IOException::class, GeneralSecurityException::class)
|
||||||
internal fun InputStream.readVersion(expectedVersion: Int? = null): Int {
|
internal fun InputStream.readVersion(expectedVersion: Int? = null): Int {
|
||||||
val version = read()
|
val version = read()
|
||||||
if (version == -1) throw IOException()
|
if (version == -1) throw IOException("File empty!")
|
||||||
if (expectedVersion != null && version != expectedVersion) {
|
if (expectedVersion != null && version != expectedVersion) {
|
||||||
throw GeneralSecurityException("Expected version $expectedVersion, not $version")
|
throw GeneralSecurityException("Expected version $expectedVersion, not $version")
|
||||||
}
|
}
|
||||||
if (version > Backup.VERSION) {
|
if (version > Backup.VERSION) {
|
||||||
// TODO maybe throw a different exception here and tell the user?
|
// 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
|
return version
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue