Skip to content

Commit

Permalink
s/fail/raise/g for rubocop
Browse files Browse the repository at this point in the history
A new version of Rubocop has introduced some additional rules about when to use fail vs. raise.
  • Loading branch information
martinb3 committed Mar 7, 2016
1 parent 7ff4137 commit b77e65a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def find_es_resource(run_context, resource_type, resource)
return name_default if name_default && !name_elasticsearch
return name_elasticsearch if name_elasticsearch && !name_default

fail "Could not find exactly one #{resource_type} resource, and no specific resource or instance name was given"
raise "Could not find exactly one #{resource_type} resource, and no specific resource or instance name was given"
end

# find exactly the resource name and type, but raise if there's multiple matches
Expand All @@ -34,7 +34,7 @@ def find_exact_resource(run_context, resource_type, resource_name)
str = ''
str << "more than one #{resource_type} was found, "
str << 'you must specify a precise resource name'
fail str
raise str
end

return result
Expand All @@ -53,7 +53,7 @@ def find_instance_name_resource(run_context, resource_type, instance_name)
str = ''
str << "more than one #{resource_type} was found, "
str << 'you must specify a precise instance name'
fail str
raise str
elsif !results.empty?
return results.first
end
Expand All @@ -67,7 +67,7 @@ def determine_version(new_resource, node)
elsif node['elasticsearch'] && node['elasticsearch']['version']
node['elasticsearch']['version'].to_s
else
fail 'could not determine version of elasticsearch to install'
raise 'could not determine version of elasticsearch to install'
end
end

Expand All @@ -77,7 +77,7 @@ def determine_install_type(new_resource, node)
elsif node['elasticsearch'] && node['elasticsearch']['install_type']
node['elasticsearch']['install_type'].to_s
else
fail 'could not determine how to install elasticsearch (package? tarball?)'
raise 'could not determine how to install elasticsearch (package? tarball?)'
end
end

Expand Down
4 changes: 2 additions & 2 deletions libraries/provider_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def whyrun_supported?
elsif install_type == 'package'
install_package_wrapper_action
else
fail "#{install_type} is not a valid install type"
raise "#{install_type} is not a valid install type"
end
end

Expand All @@ -33,7 +33,7 @@ def whyrun_supported?
elsif install_type == 'package'
remove_package_wrapper_action
else
fail "#{install_type} is not a valid install type"
raise "#{install_type} is not a valid install type"
end
end

Expand Down
4 changes: 2 additions & 2 deletions libraries/provider_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def assert_state_is_valid(es_user, es_install, es_conf)
end

unless es_conf.path_plugins[es_install.type] # we do not check existence (may not exist if no plugins installed)
fail "Could not determine the plugin directory (#{es_conf.path_plugins[es_install.type]}). Please check elasticsearch_configure[#{es_conf.name}]."
raise "Could not determine the plugin directory (#{es_conf.path_plugins[es_install.type]}). Please check elasticsearch_configure[#{es_conf.name}]."
end

unless es_conf.path_bin[es_install.type] && ::File.exist?(es_conf.path_bin[es_install.type])
fail "Could not determine the binary directory (#{es_conf.path_bin[es_install.type]}). Please check elasticsearch_configure[#{es_conf.name}]."
raise "Could not determine the binary directory (#{es_conf.path_bin[es_install.type]}). Please check elasticsearch_configure[#{es_conf.name}]."
end

return true
Expand Down
2 changes: 1 addition & 1 deletion libraries/provider_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def whyrun_supported?
end

action :remove do
fail "#{new_resource} remove not currently implemented"
raise "#{new_resource} remove not currently implemented"
end

action :configure do
Expand Down
2 changes: 1 addition & 1 deletion test/integration/helpers/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def package?
elsif rhel?
system('rpm -qa | grep elasticsearch >/dev/null 2>&1')
else
fail "I don't recognize #{os[:family]}, so I can't check for an elasticsearch package"
raise "I don't recognize #{os[:family]}, so I can't check for an elasticsearch package"
end
end

Expand Down

0 comments on commit b77e65a

Please sign in to comment.