diff --git a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb index 01c4fe7ef..3c90f4a2c 100644 --- a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +++ b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb @@ -272,7 +272,7 @@ module Vagrant if test_host_ip == "0.0.0.0" || ipv4_interfaces.detect { |iface| iface[1] == test_host_ip } is_port_open?(test_host_ip, host_port) else - raise Errors::ForwardPortHostIPNotFound + raise Errors::ForwardPortHostIPNotFound, name: @machine.name, host_ip: host_ip end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 75d649c34..4557a54e2 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -2321,10 +2321,13 @@ en: forwarding: Forwarding ports... forwarding_entry: |- %{guest_port} (guest) => %{host_port} (host) (adapter %{adapter}) - host_ip_not_found: + host_ip_not_found: |- You are trying to forward a host IP that does not exist. Please set `host_ip` to the address of an existing IPv4 network interface, or remove the option from your port forward configuration. + + VM: %{name} + Host IP: %{host_ip} non_nat: |- VirtualBox adapter #%{adapter} not configured as "NAT". Skipping port forwards on this adapter. diff --git a/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb b/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb index 8c1b24dac..48b7e3a11 100644 --- a/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb +++ b/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb @@ -233,9 +233,11 @@ describe Vagrant::Action::Builtin::HandleForwardedPortCollisions do context "when host ip does not exist" do let(:host_ip) { "127.0.0.2" } + let(:name) { "default" } - it "should raise an error" do - expect{ instance.send(:port_check, host_ip, host_port) }.to raise_error(Vagrant::Errors::ForwardPortHostIPNotFound) + it "should raise an error including the machine name" do + allow(machine).to receive(:name).and_return(name) + expect{ instance.send(:port_check, host_ip, host_port) }.to raise_error(Vagrant::Errors::ForwardPortHostIPNotFound, /#{name}/) end end end