diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-29 12:45:31 -0600 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-30 11:18:41 -0600 |
commit | 097d130a8761bca6e9f79934b0cffd2d151b302b (patch) | |
tree | 86194c05ab0b025ce0499758dd54b79691352da0 | |
parent | 079f5794af116acb4a32124684fc8965b5ba53ee (diff) | |
download | chef-097d130a8761bca6e9f79934b0cffd2d151b302b.tar.gz |
Rename NoProviderAvailable to ProviderNotFound, add alias
-rw-r--r-- | lib/chef/exceptions.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/dsc_resource.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/dsc_script.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/dsc_resource_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/dsc_script_spec.rb | 4 |
5 files changed, 10 insertions, 11 deletions
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb index 235c09c1a8..1b726d654c 100644 --- a/lib/chef/exceptions.rb +++ b/lib/chef/exceptions.rb @@ -97,7 +97,8 @@ class Chef class ConflictingMembersInGroup < ArgumentError; end class InvalidResourceReference < RuntimeError; end class ResourceNotFound < RuntimeError; end - class ProviderNotFound < ArgumentError; end + class ProviderNotFound < RuntimeError; end + NoProviderAvailable = ProviderNotFound class VerificationNotFound < RuntimeError; end # Can't find a Resource of this type that is valid on this platform. @@ -219,8 +220,6 @@ class Chef class ChildConvergeError < RuntimeError; end - class NoProviderAvailable < RuntimeError; end - class DeprecatedFeatureError < RuntimeError; def initalize(message) super("#{message} (raising error due to treat_deprecation_warnings_as_errors being set)") diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index 5fa84a21e9..379369ba6e 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -53,7 +53,7 @@ class Chef requirements.assert(:run) do |a| a.assertion { supports_dsc_invoke_resource? } err = ["You must have Powershell version >= 5.0.10018.0 to use dsc_resource."] - a.failure_message Chef::Exceptions::NoProviderAvailable, + a.failure_message Chef::Exceptions::ProviderNotFound, err a.whyrun err + ["Assuming a previous resource installs Powershell 5.0.10018.0 or higher."] a.block_action! @@ -63,7 +63,7 @@ class Chef meta_configuration['RefreshMode'] == 'Disabled' } err = ["The LCM must have its RefreshMode set to Disabled. "] - a.failure_message Chef::Exceptions::NoProviderAvailable, err.join(' ') + a.failure_message Chef::Exceptions::ProviderNotFound, err.join(' ') a.whyrun err + ["Assuming a previous resource sets the RefreshMode."] a.block_action! end diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index a75e68a475..b2432132b7 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -70,7 +70,7 @@ class Chef "Powershell 4.0 or higher was not detected on your system and is required to use the dsc_script resource.", ] a.assertion { supports_dsc? } - a.failure_message Chef::Exceptions::NoProviderAvailable, err.join(' ') + a.failure_message Chef::Exceptions::ProviderNotFound, err.join(' ') a.whyrun err + ["Assuming a previous resource installs Powershell 4.0 or higher."] a.block_action! end diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 0a6c22bdcf..65c1c019f0 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -35,10 +35,10 @@ describe Chef::Provider::DscResource do node } - it 'raises a NoProviderAvailable exception' do + it 'raises a ProviderNotFound exception' do expect(provider).not_to receive(:meta_configuration) expect{provider.run_action(:run)}.to raise_error( - Chef::Exceptions::NoProviderAvailable, /5\.0\.10018\.0/) + Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/) end end @@ -56,7 +56,7 @@ describe Chef::Provider::DscResource do expect(provider).to receive(:meta_configuration).and_return( meta_configuration) expect { provider.run_action(:run) }.to raise_error( - Chef::Exceptions::NoProviderAvailable, /Disabled/) + Chef::Exceptions::ProviderNotFound, /Disabled/) end end diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index d4b2eb3b22..76589e71c1 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -158,14 +158,14 @@ describe Chef::Provider::DscScript do expect { provider.run_action(:run) - }.to raise_error(Chef::Exceptions::NoProviderAvailable) + }.to raise_error(Chef::Exceptions::ProviderNotFound) end end it 'raises an exception if Powershell is not present' do expect { provider.run_action(:run) - }.to raise_error(Chef::Exceptions::NoProviderAvailable) + }.to raise_error(Chef::Exceptions::ProviderNotFound) end end |