summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNimishaS <nimisha.sharad@msystechnologies.com>2016-10-03 09:27:36 +0000
committerNimishaS <nimisha.sharad@msystechnologies.com>2016-10-03 09:27:36 +0000
commitaf13c7a425e990232d6ff0a1739ff81ed12b55cd (patch)
treef8ddb75582c84adddbb53e1dd5ff5a6b886b4198
parentc8ba46a99e255414576f94afee0f034ccf24d0bf (diff)
downloadchef-af13c7a425e990232d6ff0a1739ff81ed12b55cd.tar.gz
Raising Mixlib::ShellOut::ShellCommandFailed exception
Signed-off-by: NimishaS <nimisha.sharad@msystechnologies.com>
-rw-r--r--lib/chef/mixin/powershell_out.rb4
-rw-r--r--spec/functional/mixin/powershell_out_spec.rb2
-rw-r--r--spec/unit/mixin/powershell_out_spec.rb2
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/mixin/powershell_out.rb b/lib/chef/mixin/powershell_out.rb
index 67698ed5b1..3e1f588319 100644
--- a/lib/chef/mixin/powershell_out.rb
+++ b/lib/chef/mixin/powershell_out.rb
@@ -37,9 +37,9 @@ class Chef
result = run_command_with_os_architecture(script, options)
if result.stderr.include? "A positional parameter cannot be found that accepts argument"
- raise "Please use single escape for special characters in powershell_out."
+ raise Mixlib::ShellOut::ShellCommandFailed, "Please use single escape for special characters in powershell_out. \n #{result.stderr}"
elsif result.stderr != ""
- raise result.stderr
+ raise Mixlib::ShellOut::ShellCommandFailed, result.stderr
end
result
end
diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb
index 9a210100e0..31bf397569 100644
--- a/spec/functional/mixin/powershell_out_spec.rb
+++ b/spec/functional/mixin/powershell_out_spec.rb
@@ -33,7 +33,7 @@ describe Chef::Mixin::PowershellOut, windows_only: true do
end
it "raises exceptions when the command is invalid" do
- expect { powershell_out!("this-is-not-a-valid-command").run_command }.to raise_error(RuntimeError)
+ expect { powershell_out!("this-is-not-a-valid-command").run_command }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
end
end
diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb
index c37fc4c8d9..9524557c4c 100644
--- a/spec/unit/mixin/powershell_out_spec.rb
+++ b/spec/unit/mixin/powershell_out_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
end
it "raises error if double quote is passed with double escape characters" do
- expect { object.powershell_out("Write-Verbose \\\"Some String\\\" -Verbose") }.to raise_error("Please use single escape for special characters in powershell_out.")
+ expect { object.powershell_out("Write-Verbose \\\"Some String\\\" -Verbose") }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
end
end