fix pscommand error messaging

This commit is contained in:
Matt Wrock 2015-06-05 22:24:05 -07:00
parent 740877065a
commit e6daf2f172
3 changed files with 21 additions and 6 deletions

View File

@ -91,7 +91,7 @@ module VagrantPlugins
args << "-password" << ps_info[:password] args << "-password" << ps_info[:password]
result = Vagrant::Util::PowerShell.execute(script_path, *args) result = Vagrant::Util::PowerShell.execute(script_path, *args)
if result.exit_code != 0 if result.exit_code != 0
raise Errors::PowershellError, raise Errors::PowerShellError,
script: script_path, script: script_path,
stderr: result.stderr stderr: result.stderr
end end
@ -108,7 +108,7 @@ module VagrantPlugins
args << "-hostname" << ps_info[:host] args << "-hostname" << ps_info[:host]
result = Vagrant::Util::PowerShell.execute(script_path, *args) result = Vagrant::Util::PowerShell.execute(script_path, *args)
if result.exit_code != 0 if result.exit_code != 0
raise Errors::PowershellError, raise Errors::PowerShellError,
script: script_path, script: script_path,
stderr: result.stderr stderr: result.stderr
end end

View File

@ -2,17 +2,21 @@ module VagrantPlugins
module CommandPS module CommandPS
module Errors module Errors
# A convenient superclass for all our errors. # A convenient superclass for all our errors.
class PSError < Vagrant::Errors::VagrantError class PSCommandError < Vagrant::Errors::VagrantError
error_namespace("vagrant_ps.errors") error_namespace("vagrant_ps.errors")
end end
class HostUnsupported < PSError class HostUnsupported < PSCommandError
error_key(:host_unsupported) error_key(:host_unsupported)
end end
class PSRemotingUndetected < PSError class PSRemotingUndetected < PSCommandError
error_key(:ps_remoting_undetected) error_key(:ps_remoting_undetected)
end end
class PowerShellError < PSCommandError
error_key(:powershell_error)
end
end end
end end
end end

View File

@ -3,7 +3,7 @@ en:
detecting: |- detecting: |-
Detecting if a remote PowerShell connection can be made with the guest... Detecting if a remote PowerShell connection can be made with the guest...
reseting: |- reseting: |-
Reseting WinRM TrustedHosts to their original value. Resetting WinRM TrustedHosts to their original value.
errors: errors:
host_unsupported: |- host_unsupported: |-
@ -14,3 +14,14 @@ en:
Unable to establish a remote PowerShell connection with the guest. Unable to establish a remote PowerShell connection with the guest.
Check if the firewall rules on the guest allow connections to the Check if the firewall rules on the guest allow connections to the
Windows remote management service. Windows remote management service.
powershell_error: |-
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: %{script}
Error:
%{stderr}