summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-05-02 15:36:30 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-05-02 15:36:30 -0700
commitd4df6cc2274e119fb2a67bca0912667b0fef7866 (patch)
tree8c5bd026ecf070fa404623a4b658de296342a5ad /lib/puppet/interface
parent8b28417f696bd7d34ea4212a89913b5e796993c7 (diff)
parent1b42725b5caab6f8e457e11fec2488fbe94e8e43 (diff)
downloadpuppet-d4df6cc2274e119fb2a67bca0912667b0fef7866.tar.gz
puppet-d4df6cc2274e119fb2a67bca0912667b0fef7866.tar.xz
puppet-d4df6cc2274e119fb2a67bca0912667b0fef7866.zip
Merge branch 'bug/2.7.x/7314-backtrace-when-face-has-syntax-error' into 2.7.x
Diffstat (limited to 'lib/puppet/interface')
-rw-r--r--lib/puppet/interface/face_collection.rb21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb
index 6e6afc545..baa424692 100644
--- a/lib/puppet/interface/face_collection.rb
+++ b/lib/puppet/interface/face_collection.rb
@@ -10,21 +10,12 @@ module Puppet::Interface::FaceCollection
unless @loaded
@loaded = true
$LOAD_PATH.each do |dir|
- next unless FileTest.directory?(dir)
- Dir.chdir(dir) do
- Dir.glob("puppet/face/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
- iname = file.sub(/\.rb/, '')
- begin
- require iname
- rescue Exception => detail
- puts detail.backtrace if Puppet[:trace]
- raise "Could not load #{iname} from #{dir}/#{file}: #{detail}"
- end
- end
- end
+ Dir.glob("#{dir}/puppet/face/*.rb").
+ collect {|f| File.basename(f, '.rb') }.
+ each {|name| self[name, :current] }
end
end
- return @faces.keys.select {|name| @faces[name].length > 0 }
+ @faces.keys.select {|name| @faces[name].length > 0 }
end
def self.validate_version(version)
@@ -124,6 +115,10 @@ module Puppet::Interface::FaceCollection
rescue LoadError => e
raise unless e.message =~ %r{-- puppet/face/#{name}$}
# ...guess we didn't find the file; return a much better problem.
+ rescue SyntaxError => e
+ raise unless e.message =~ %r{puppet/face/#{name}\.rb:\d+: }
+ Puppet.err "Failed to load face #{name}:\n#{e}"
+ # ...but we just carry on after complaining.
end
return get_face(name, version)