Skip to content

Commit 1ad21a0

Browse files
committed
Correct error handling in require ruby-pwsh
The error handling around the require for 'ruby-pwsh' tries to rescue with nil, but does not pass an argument to rescue which by default will rescue only StandardError. In this case it should rescue the LoadError which is not a StandardError: LoadError.is_a? StandardError => false
1 parent a9adf9b commit 1ad21a0

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

lib/puppet/provider/iis_application/webadministration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def self.powershell_path
1414
require 'ruby-pwsh'
1515
Pwsh::Manager.powershell_path
16-
rescue
16+
rescue LoadError
1717
nil
1818
end
1919

lib/puppet/provider/iis_application_pool/webadministration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def self.powershell_path
1414
require 'ruby-pwsh'
1515
Pwsh::Manager.powershell_path
16-
rescue
16+
rescue LoadError
1717
nil
1818
end
1919

lib/puppet/provider/iis_feature/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def self.powershell_path
1616
require 'ruby-pwsh'
1717
Pwsh::Manager.powershell_path
18-
rescue
18+
rescue LoadError
1919
nil
2020
end
2121

lib/puppet/provider/iis_site/iisadministration.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'pathname'
4-
require 'ruby-pwsh'
54

65
Puppet::Type.type(:iis_site).provide(:iisadministration) do
76
desc 'IIS Provider using the PowerShell IISAdministration module'
@@ -15,7 +14,7 @@
1514
def self.powershell_path
1615
require 'ruby-pwsh'
1716
Pwsh::Manager.powershell_path
18-
rescue
17+
rescue LoadError
1918
nil
2019
end
2120

lib/puppet/provider/iis_site/webadministration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def self.powershell_path
2020
require 'ruby-pwsh'
2121
Pwsh::Manager.powershell_path
22-
rescue
22+
rescue LoadError
2323
nil
2424
end
2525

lib/puppet/provider/iis_virtual_directory/webadministration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def self.powershell_path
1515
require 'ruby-pwsh'
1616
Pwsh::Manager.powershell_path
17-
rescue
17+
rescue LoadError
1818
nil
1919
end
2020

0 commit comments

Comments
 (0)