From: Peter Palfrader <peter@palfrader.org>
Date: Tue, 1 Mar 2011 10:07:57 +0000 (+0100)
Subject: Way more painful than is legal
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=377748bbc8dc5824bb518905c0f618b27d5e9ea5;p=dsa-puppet.git

Way more painful than is legal
---

diff --git a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
index d0321846..84b618c3 100644
--- a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
+++ b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
@@ -17,7 +17,7 @@ module Puppet::Parser::Functions
         yaml.keys.each do |hoster|
           if yaml[hoster].kind_of?(Array)
             netrange = yaml[hoster]
-          elsif yaml[hoster].kind_of?(Array) and yaml[hoster].has_key?['netrange']
+          elsif yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
             netrange = yaml[hoster]['netrange']
           else
             next
@@ -25,10 +25,10 @@ module Puppet::Parser::Functions
           netrange.each do |net|
             begin
               if IPAddr.new(net).include?(addr)
-                return hoster
+                ans = hoster
               end
-            rescue
-              raise "Could not match addr #{addr} for net #{net}"
+            rescue Exception => e
+              raise "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
             end
           end
         end