Add a clean error message for invalid IP addresses
This commit is contained in:
parent
2b4a69964e
commit
4a4183398b
|
@ -448,6 +448,10 @@ module Vagrant
|
|||
error_key(:collides, "vagrant.actions.vm.host_only_network")
|
||||
end
|
||||
|
||||
class NetworkAddressInvalid < VagrantError
|
||||
error_key(:network_address_invalid)
|
||||
end
|
||||
|
||||
class NetworkDHCPAlreadyAttached < VagrantError
|
||||
error_key(:dhcp_already_attached, "vagrant.actions.vm.network")
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require "ipaddr"
|
||||
require "resolv"
|
||||
require "set"
|
||||
|
||||
require "log4r"
|
||||
|
@ -258,7 +259,12 @@ module VagrantPlugins
|
|||
# Default IP is in the 20-bit private network block for DHCP based networks
|
||||
options[:ip] = "172.28.128.1" if options[:type] == :dhcp && !options[:ip]
|
||||
|
||||
ip = IPAddr.new(options[:ip])
|
||||
begin
|
||||
ip = IPAddr.new(options[:ip])
|
||||
rescue IPAddr::InvalidAddressError => e
|
||||
raise Vagrant::Errors::NetworkAddressInvalid, :ip => options[:ip], :error_msg => e.message
|
||||
end
|
||||
|
||||
if ip.ipv4?
|
||||
options[:netmask] ||= "255.255.255.0"
|
||||
|
||||
|
|
|
@ -891,6 +891,11 @@ en:
|
|||
%{message}
|
||||
network_type_not_supported: |-
|
||||
The %{type} network type is not supported for this box or guest.
|
||||
network_address_invalid: |-
|
||||
The IP address '%{ip}' is not valid. Please review the error message
|
||||
below to help resolve the issue:
|
||||
|
||||
%{error_msg}
|
||||
network_manager_not_installed: |-
|
||||
Vagrant was instructed to configure the %{device} network device to
|
||||
be managed by NetworkManager. However, the configured guest VM does
|
||||
|
|
Loading…
Reference in New Issue