diff --git a/Sources/tart/PIDLock.swift b/Sources/tart/PIDLock.swift index bfe8812..23d4253 100644 --- a/Sources/tart/PIDLock.swift +++ b/Sources/tart/PIDLock.swift @@ -11,7 +11,7 @@ class PIDLock { if fd == -1 { let details = Errno(rawValue: CInt(errno)) - throw RuntimeError.PIDLockFailed("failed to open lock file \(url): \(details)") + throw RuntimeError.PIDLockMissing("failed to open lock file \(url): \(details)") } } diff --git a/Sources/tart/VMStorageHelper.swift b/Sources/tart/VMStorageHelper.swift index 4774d16..9f26557 100644 --- a/Sources/tart/VMStorageHelper.swift +++ b/Sources/tart/VMStorageHelper.swift @@ -24,6 +24,8 @@ class VMStorageHelper { private static func missingVMWrap(_ name: String, closure: () throws -> R) throws -> R { do { return try closure() + } catch RuntimeError.PIDLockMissing { + throw RuntimeError.VMDoesNotExist(name: name) } catch { if error.isFileNotFound() { throw RuntimeError.VMDoesNotExist(name: name) @@ -59,6 +61,7 @@ enum RuntimeError : Error { case InvalidDiskSize(_ message: String) case FailedToUpdateAccessDate(_ message: String) case PIDLockFailed(_ message: String) + case PIDLockMissing(_ message: String) case FailedToParseRemoteName(_ message: String) case VMTerminationFailed(_ message: String) case ImproperlyFormattedHost(_ host: String, _ hint: String) @@ -105,6 +108,8 @@ extension RuntimeError : CustomStringConvertible { return message case .PIDLockFailed(let message): return message + case .PIDLockMissing(let message): + return message case .FailedToParseRemoteName(let cause): return "failed to parse remote name: \(cause)" case .VMTerminationFailed(let message):