]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Try to get useful error messages
authorPeter Palfrader <peter@palfrader.org>
Wed, 2 Mar 2011 12:00:22 +0000 (13:00 +0100)
committerPeter Palfrader <peter@palfrader.org>
Wed, 2 Mar 2011 12:00:22 +0000 (13:00 +0100)
modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb

index a71617e53aff13b6a802f5eb51901352aaf10174..06b074d8ddd741507817b2764429ffa2c659ede2 100644 (file)
@@ -1,18 +1,22 @@
 module Puppet::Parser::Functions
   newfunction(:allnodeinfo, :type => :rvalue) do |args|
-    required = args.shift.split()
-    optional = args.shift.split()
+    begin
+      required = args.shift.split()
+      optional = args.shift.split()
 
-    allhosts = function_ldapinfo('*', required+optional )
-    res = {}
-    allhosts.each_pair do |hostname, host|
-        # If a returned value doesn't have all the attributes we're searching for, skip
-        # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes
-        next if required.any?{ |a| not host[a] or host[a].empty? }
-        res[hostname] = host
-    end
+      allhosts = function_ldapinfo('*', required+optional )
+      res = {}
+      allhosts.each_pair do |hostname, host|
+          # If a returned value doesn't have all the attributes we're searching for, skip
+          # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes
+          next if required.any?{ |a| not host[a] or host[a].empty? }
+          res[hostname] = host
+      end
 
-    return res
+      return res
+    rescue => e
+      raise Puppet::ParseError, "Error in allnodeinfo: #{e.message}\n#{e.backtrace}"
+    end
   end
 end
 # vim:set et: