mirror of https://github.com/cirruslabs/tart.git
Return exit code 2 on RuntimeError.VMDoesNotExist (#597)
* Return exit code 2 on RuntimeError.VMDoesNotExist * Upgrade isFileNotFound() do detect underlying errors
This commit is contained in:
parent
4bb248e7b4
commit
d4d3852745
|
|
@ -34,9 +34,15 @@ class VMStorageHelper {
|
|||
}
|
||||
}
|
||||
|
||||
extension NSError {
|
||||
func isFileNotFound() -> Bool {
|
||||
return self.code == NSFileNoSuchFileError || self.code == NSFileReadNoSuchFileError
|
||||
}
|
||||
}
|
||||
|
||||
extension Error {
|
||||
func isFileNotFound() -> Bool {
|
||||
(self as NSError).code == NSFileReadNoSuchFileError
|
||||
(self as NSError).isFileNotFound() || (self as NSError).underlyingErrors.contains(where: { $0.isFileNotFound() })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,6 +117,8 @@ extension RuntimeError : CustomStringConvertible {
|
|||
extension RuntimeError : HasExitCode {
|
||||
var exitCode: Int32 {
|
||||
switch self {
|
||||
case .VMDoesNotExist:
|
||||
return 2
|
||||
case .VMNotRunning:
|
||||
return 2
|
||||
case .VMAlreadyRunning:
|
||||
|
|
|
|||
Loading…
Reference in New Issue