Skip to content

Commit

Permalink
Friendly decompression error message (#835)
Browse files Browse the repository at this point in the history
* Friendly decompression error message

* Wrap FilterError
  • Loading branch information
fkorotkov authored May 31, 2024
1 parent c655288 commit dd46033
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/tart/VMDirectory+OCI.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Compression
import Foundation
import Sentry

Expand Down Expand Up @@ -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...")
Expand Down
3 changes: 3 additions & 0 deletions Sources/tart/VMStorageHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit dd46033

Please sign in to comment.