summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-09 16:17:17 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-03-09 16:52:08 -0800
commit285c4cc4b056b9c4990738c3d479d1a8993cf959 (patch)
treee086ed1a5f1637f2c0bb521f26b9906eab6bf35c /lib/puppet/parser
parenteae17c3cba159d895e5ec2e87e4abe8c125a9562 (diff)
downloadpuppet-285c4cc4b056b9c4990738c3d479d1a8993cf959.tar.gz
puppet-285c4cc4b056b9c4990738c3d479d1a8993cf959.tar.xz
puppet-285c4cc4b056b9c4990738c3d479d1a8993cf959.zip
(#5392) Give a better error when realizing a non-existant resource
You can reproduce the error with a simple manifest Bogus_type <| title == 'foo' |> We used to fail because find_resource_type returned nil and we never checked if it was nil before calling methods on it. Reviewed-by: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/collection.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index ef36b7143..565b83195 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -16,6 +16,7 @@ class Puppet::Parser::AST
str, code = query && query.safeevaluate(scope)
resource_type = scope.find_resource_type(@type)
+ fail "Resource type #{@type} doesn't exist" unless resource_type
newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form)
scope.compiler.add_collection(newcoll)
@@ -26,10 +27,10 @@ class Puppet::Parser::AST
params = @override.collect { |param| param.safeevaluate(scope) }
newcoll.add_override(
:parameters => params,
- :file => @file,
- :line => @line,
- :source => scope.source,
- :scope => scope
+ :file => @file,
+ :line => @line,
+ :source => scope.source,
+ :scope => scope
)
end