Skip to content

Commit

Permalink
Improve tart ip error message (#464)
Browse files Browse the repository at this point in the history
Resolves #460
  • Loading branch information
fkorotkov authored Apr 5, 2023
1 parent 92a4b31 commit 261c180
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Sources/tart/Commands/IP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ struct IP: AsyncParsableCommand {
let vmConfig = try VMConfig.init(fromURL: vmDir.configURL)
let vmMACAddress = MACAddress(fromString: vmConfig.macAddress.string)!

guard let ip = try await IP.resolveIP(vmMACAddress, resolutionStrategy: resolver, secondsToWait: wait) else {
if try !vmDir.running() {
throw RuntimeError.NoIPAddressFound("no IP address found, is your VM running?")
}

guard let ip = try await IP.resolveIP(vmMACAddress, resolutionStrategy: resolver, secondsToWait: wait) else {
if (vmConfig.os == .linux && resolver == .arp) {
throw RuntimeError.NoIPAddressFound("no IP address found, not all Linux distributions are compatible with ARP resolver")
}
throw RuntimeError.NoIPAddressFound("no IP address found")
}
print(ip)
}

Expand Down

0 comments on commit 261c180

Please sign in to comment.