Skip to content

Commit 05769c0

Browse files
author
Christopher Brown
committed
Changed all uses of Chef::Exception to Chef::Exceptions to avoid masking ::Exception in places like popen4
1 parent 8ff56c0 commit 05769c0

43 files changed

Lines changed: 133 additions & 133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chef-server/lib/chef/search_index.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def create_index_object(new_object)
4444
elsif new_object.kind_of?(Hash)
4545
index_hash = new_object
4646
else
47-
raise Chef::Exception::SearchIndex, "Cannot transform argument to a Hash!"
47+
raise Chef::Exceptions::SearchIndex, "Cannot transform argument to a Hash!"
4848
end
4949

5050
unless index_hash.has_key?(:index_name) || index_hash.has_key?("index_name")
51-
raise Chef::Exception::SearchIndex, "Cannot index without an index_name key: #{index_hash.inspect}"
51+
raise Chef::Exceptions::SearchIndex, "Cannot index without an index_name key: #{index_hash.inspect}"
5252
end
5353

5454
unless index_hash.has_key?(:id) || index_hash.has_key?("id")
55-
raise Chef::Exception::SearchIndex, "Cannot index without an id key: #{index_hash.inspect}"
55+
raise Chef::Exceptions::SearchIndex, "Cannot index without an id key: #{index_hash.inspect}"
5656
end
5757

5858
index_hash.each do |k,v|

chef/lib/chef/exceptions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# limitations under the License.
1717

1818
class Chef
19-
class Exception
19+
class Exceptions
2020
class Cron < RuntimeError; end
2121
class Exec < RuntimeError; end
2222
class FileNotFound < RuntimeError; end

chef/lib/chef/file_cache.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def move_to(file, path)
9898
# String:: A string with the file contents, or the path to the file.
9999
#
100100
# === Raises
101-
# Chef::Exception::FileNotFound:: If it cannot find the file in the cache
101+
# Chef::Exceptions::FileNotFound:: If it cannot find the file in the cache
102102
def load(path, read=true)
103103
validate(
104104
{
@@ -109,7 +109,7 @@ def load(path, read=true)
109109
}
110110
)
111111
cache_path = create_cache_path(path, false)
112-
raise Chef::Exception::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exists?(cache_path)
112+
raise Chef::Exceptions::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exists?(cache_path)
113113
if read
114114
File.read(cache_path)
115115
else
@@ -202,4 +202,4 @@ def create_cache_path(path, create_if_missing=true)
202202

203203
end
204204
end
205-
end
205+
end

chef/lib/chef/mixin/command.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def run_command(args={})
144144

145145
args[:cwd] ||= Dir.tmpdir
146146
unless File.directory?(args[:cwd])
147-
raise Chef::Exception::Exec, "#{args[:cwd]} does not exist or is not a directory"
147+
raise Chef::Exceptions::Exec, "#{args[:cwd]} does not exist or is not a directory"
148148
end
149149

150150
Chef::Log.debug("Executing #{args[:command]}")
@@ -177,7 +177,7 @@ def run_command(args={})
177177
output << "#{command_stderr}\n"
178178
output << "---- End #{args[:command]} STDERR ----\n"
179179
end
180-
raise Chef::Exception::Exec, "#{args[:command_string]} returned #{status.exitstatus}, expected #{args[:returns]}#{output}"
180+
raise Chef::Exceptions::Exec, "#{args[:command_string]} returned #{status.exitstatus}, expected #{args[:returns]}#{output}"
181181
end
182182
end
183183
Chef::Log.debug("Ran #{args[:command_string]} (#{args[:command]}) returned #{status.exitstatus}")
@@ -191,9 +191,9 @@ def run_command(args={})
191191
# modified to suit the needs of Chef. Any bugs here are most likely
192192
# my own, and not Ara's.
193193
#
194-
# The original appears in external/open4.rb in it's unmodified form.
194+
# The original appears in external/open4.rb in its unmodified form.
195195
#
196-
# Thanks, Ara.
196+
# Thanks Ara!
197197
def popen4(cmd, args={}, &b)
198198

199199
# Waitlast - this is magic.

chef/lib/chef/mixin/find_preferred_file.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def find_preferred_file(cookbook_id, file_type, file_name, fqdn, platform, versi
8888
end
8989

9090
unless to_send
91-
raise Chef::Exception::FileNotFound, "Cannot find a preferred file for #{file_name}!"
91+
raise Chef::Exceptions::FileNotFound, "Cannot find a preferred file for #{file_name}!"
9292
end
9393

9494
to_send
9595
end
9696

9797
end
9898
end
99-
end
99+
end

chef/lib/chef/provider.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def initialize(node, new_resource)
2828
end
2929

3030
def load_current_resource
31-
raise Chef::Exception::Override, "You must override load_current_resource in #{self.to_s}"
31+
raise Chef::Exceptions::Override, "You must override load_current_resource in #{self.to_s}"
3232
end
3333

3434
def action_nothing
@@ -37,4 +37,4 @@ def action_nothing
3737
end
3838

3939
end
40-
end
40+
end

chef/lib/chef/provider/cron.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def load_current_resource
3939
stdout.each { |line| crontab << line }
4040
end
4141
if status.exitstatus > 1
42-
raise Chef::Exception::Cron, "Error determining state of #{@new_resource.name}, exit: #{status.exitstatus}"
42+
raise Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: #{status.exitstatus}"
4343
elsif status.exitstatus == 0
4444
crontab.each do |line|
4545
case line

chef/lib/chef/provider/group.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ def action_modify
102102
Chef::Log.info("Modified #{@new_resource}")
103103
end
104104
else
105-
raise Chef::Exception::Group, "Cannot modify #{@new_resource} - group does not exist!"
105+
raise Chef::Exceptions::Group, "Cannot modify #{@new_resource} - group does not exist!"
106106
end
107107
end
108108
end
109109
end
110-
end
110+
end

chef/lib/chef/provider/group/groupadd.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def load_current_resource
2828
"/usr/sbin/groupmod",
2929
"/usr/sbin/groupdel",
3030
"/usr/bin/gpasswd" ].each do |required_binary|
31-
raise Chef::Exception::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
31+
raise Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
3232
end
3333
end
3434

@@ -82,4 +82,4 @@ def set_options
8282
end
8383
end
8484
end
85-
end
85+
end

chef/lib/chef/provider/mount.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def action_umount
5858

5959
def action_remount
6060
unless @new_resource.supports[:remount]
61-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :remount"
61+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
6262
else
6363
if @current_resource.mounted
6464
Chef::Log.debug("#{@new_resource}: attempting to remount")
@@ -98,23 +98,23 @@ def action_disable
9898
end
9999

100100
def mount_fs
101-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :mount"
101+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :mount"
102102
end
103103

104104
def umount_fs
105-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :umount"
105+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :umount"
106106
end
107107

108108
def remount_fs
109-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :remount"
109+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :remount"
110110
end
111111

112112
def enable_fs
113-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :enable"
113+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"
114114
end
115115

116116
def disable_fs
117-
raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :disable"
117+
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"
118118
end
119119
end
120120
end

0 commit comments

Comments
 (0)