summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-19 19:16:10 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-19 19:16:10 +0000
commit9b5833a63cc88fff7ce8e157e6ab079d3fd3f631 (patch)
treef367096862d5f24cd55bcb0b88e4a2efd41682dc /lib
parent1f8b768e4ebef4e9ee54ee96db2544d6f9522bbf (diff)
downloadpuppet-9b5833a63cc88fff7ce8e157e6ab079d3fd3f631.tar.gz
puppet-9b5833a63cc88fff7ce8e157e6ab079d3fd3f631.tar.xz
puppet-9b5833a63cc88fff7ce8e157e6ab079d3fd3f631.zip
Clarifying the errors a bit when nodes come from external sources.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2324 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/error.rb6
-rw-r--r--lib/puppet/parser/functions.rb20
-rw-r--r--lib/puppet/parser/grammar.ra4
-rw-r--r--lib/puppet/parser/interpreter.rb15
-rw-r--r--lib/puppet/parser/parser.rb8
5 files changed, 34 insertions, 19 deletions
diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb
index b70a4dddf..10ccf47be 100644
--- a/lib/puppet/error.rb
+++ b/lib/puppet/error.rb
@@ -22,12 +22,14 @@ module Puppet # :nodoc:
def to_s
str = nil
- if defined? @file and defined? @line and @file and @line
+ if self.file and self.line
str = "%s at %s:%s" %
[@message.to_s, @file, @line]
- elsif defined? @line and @line
+ elsif self.line
str = "%s at line %s" %
[@message.to_s, @line]
+ elsif self.file
+ str = "%s in %s" % [@message.to_s, self.file]
else
str = @message.to_s
end
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index b02ea4308..1f9c8f519 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -113,13 +113,19 @@ module Functions
! klasses.include?(klass)
end
- # Throw an error if we didn't evaluate all of the classes.
- if missing.length == 1
- self.fail Puppet::ParseError,
- "Could not find class %s" % missing
- elsif missing.length > 1
- self.fail Puppet::ParseError,
- "Could not find classes %s" % missing.join(", ")
+ unless missing.empty?
+ # Throw an error if we didn't evaluate all of the classes.
+ str = "Could not find class"
+ if missing.length > 1
+ str += "es"
+ end
+
+ str += " " + missing.join(", ")
+
+ if n = namespaces and ! n.empty? and n != [""]
+ str += " in namespaces %s" % @namespaces.join(", ")
+ end
+ self.fail Puppet::ParseError, str
end
end
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index b76e8c314..6bca6495e 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -635,11 +635,11 @@ end
# available.
def ast(klass, hash = nil)
hash ||= {}
- unless hash[:line]
+ unless hash.include?(:line)
hash[:line] = @lexer.line
end
- unless hash[:file]
+ unless hash.include?(:file)
if file = @lexer.file
hash[:file] = file
end
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 5eb44c39c..936bc31eb 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -314,7 +314,7 @@ class Puppet::Parser::Interpreter
end
# Create a new node, just from a list of names, classes, and an optional parent.
- def gennode(name, hash)
+ def gennode(name, hash, source = nil)
facts = hash[:facts]
classes = hash[:classes]
parent = hash[:parentnode]
@@ -348,7 +348,14 @@ class Puppet::Parser::Interpreter
end
# Create the node
- return @parser.ast(AST::Node, arghash)
+ if source
+ arghash[:file] = source
+ else
+ arghash[:file] = nil
+ end
+ arghash[:line] = nil
+ node = @parser.ast(AST::Node, arghash)
+ return node
end
# create our interpreter
@@ -716,7 +723,7 @@ class Puppet::Parser::Interpreter
Puppet.warning "Somehow got a node with no information"
return nil
else
- return gennode(name, args)
+ return gennode(name, args, Puppet[:external_nodes])
end
end
@@ -727,7 +734,7 @@ class Puppet::Parser::Interpreter
args = {}
args[:classes] = classes if classes
args[:parentnode] = parent if parent
- return gennode(node, args)
+ return gennode(node, args, "ldap")
else
return nil
end
diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb
index a4c2da63e..8b75200b5 100644
--- a/lib/puppet/parser/parser.rb
+++ b/lib/puppet/parser/parser.rb
@@ -29,7 +29,7 @@ module Puppet
class Parser < Racc::Parser
-module_eval <<'..end grammar.ra modeval..id729500608d', 'grammar.ra', 603
+module_eval <<'..end grammar.ra modeval..idde6e0009a9', 'grammar.ra', 603
require 'puppet/parser/functions'
attr_reader :file, :interp
@@ -65,11 +65,11 @@ end
# available.
def ast(klass, hash = nil)
hash ||= {}
- unless hash[:line]
+ unless hash.include?(:line)
hash[:line] = @lexer.line
end
- unless hash[:file]
+ unless hash.include?(:file)
if file = @lexer.file
hash[:file] = file
end
@@ -254,7 +254,7 @@ end
# $Id$
-..end grammar.ra modeval..id729500608d
+..end grammar.ra modeval..idde6e0009a9
##### racc 1.4.5 generates ###