diff options
Diffstat (limited to 'lib/chef/powershell.rb')
-rw-r--r-- | lib/chef/powershell.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/powershell.rb b/lib/chef/powershell.rb index b1f8c5396c..9790a3c10f 100644 --- a/lib/chef/powershell.rb +++ b/lib/chef/powershell.rb @@ -39,12 +39,26 @@ class Chef exec(script) end + # + # Was there an error running the command + # + # @return [Boolean] + # def error? return true if errors.count > 0 false end + class CommandFailed < RuntimeError; end + + # + # @raise [Chef::PowerShell::CommandFailed] raise if the command failed + # + def error! + raise Chef::PowerShell::CommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error? + end + private def exec(script) |