summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2011-02-01 17:23:23 -0800
committerPaul Berry <paul@puppetlabs.com>2011-02-01 17:23:23 -0800
commited1359902d14a0ca89dac5debee756209b0bd433 (patch)
tree03337bc864c01fffe2e2c9b2210b6425f71caf16
parent526335cff0f47c1efc25ffda535e2ead10f10fac (diff)
parent87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5 (diff)
downloadpuppet-ed1359902d14a0ca89dac5debee756209b0bd433.tar.gz
puppet-ed1359902d14a0ca89dac5debee756209b0bd433.tar.xz
puppet-ed1359902d14a0ca89dac5debee756209b0bd433.zip
Merge remote branch 'bodepd/feature/2.6.4/5910' into 2.6.next
* bodepd/feature/2.6.4/5910: (#5910) Improved logging when declared classes cannot be found:
-rw-r--r--lib/puppet/resource.rb9
-rwxr-xr-xspec/unit/resource_spec.rb8
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index b0a3ecee6..e832804f5 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -205,8 +205,13 @@ class Puppet::Resource
tag(self.title) if valid_tag?(self.title)
@reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x
-
- raise ArgumentError, "Invalid resource type #{type}" if strict? and ! resource_type
+ if strict? and ! resource_type
+ if @type == 'Class'
+ raise ArgumentError, "Could not find declared class #{title}"
+ else
+ raise ArgumentError, "Invalid resource type #{type}"
+ end
+ end
end
def ref
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 877b6b6b0..ff31b2492 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -98,6 +98,14 @@ describe Puppet::Resource do
lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError)
end
+ it 'should fail if strict is set and type does not exist' do
+ lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo')
+ end
+
+ it 'should fail if strict is set and class does not exist' do
+ lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo')
+ end
+
it "should fail if the title is a hash and the type is not a valid resource reference string" do
lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError,
'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?'