Friendly decompression error message (#835)

* Friendly decompression error message

* Wrap FilterError
This commit is contained in:
Fedor Korotkov
2024-05-31 14:47:41 +00:00
committed by GitHub
parent c655288de7
commit dd46033812
2 changed files with 11 additions and 2 deletions
+8 -2
View File
@@ -1,3 +1,4 @@
import Compression
import Foundation
import Sentry
@@ -53,8 +54,13 @@ extension VMDirectory {
let progress = Progress(totalUnitCount: diskCompressedSize)
ProgressObserver(progress).log(defaultLogger)
try await diskImplType.pull(registry: registry, diskLayers: layers, diskURL: diskURL, concurrency: concurrency, progress: progress,
localLayerCache: localLayerCache)
do {
try await diskImplType.pull(registry: registry, diskLayers: layers, diskURL: diskURL,
concurrency: concurrency, progress: progress,
localLayerCache: localLayerCache)
} catch let error where error is FilterError {
throw RuntimeError.PullFailed("failed to decompress disk: \(error.localizedDescription)")
}
// Pull VM's NVRAM file layer and store it in an NVRAM file
defaultLogger.appendNewLine("pulling NVRAM...")
+3
View File
@@ -69,6 +69,7 @@ enum RuntimeError : Error {
case OCIStorageError(_ message: String)
case OCIUnsupportedDiskFormat(_ format: String)
case SuspendFailed(_ message: String)
case PullFailed(_ message: String)
}
protocol HasExitCode {
@@ -122,6 +123,8 @@ extension RuntimeError : CustomStringConvertible {
return "OCI disk format \(format) is not supported by this version of Tart"
case .SuspendFailed(let message):
return "Failed to suspend the VM: \(message)"
case .PullFailed(let message):
return message
}
}
}