[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Pieter van de Bruggen pieter at puppetlabs.com
Tue May 10 08:18:23 UTC 2011


The following commit has been merged in the experimental branch:
commit c627fad08c4866fbef300e887750c29963985635
Author: Pieter van de Bruggen <pieter at puppetlabs.com>
Date:   Tue Apr 26 16:34:25 2011 -0700

    (#7251) Let exceptions raised in decorators rise.
    
    This allows users to write before_action advice that does basic
    option validation very easily.
    
    Reviewed-By: Daniel Pittman

diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index ced0086..ba68ac6 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -139,12 +139,10 @@ class Puppet::Interface
       action.get_option(name).__decoration_name(type)
     end
 
+    # Exceptions here should propagate up; this implements a hook we can use
+    # reasonably for option validation.
     methods.each do |hook|
-      begin
-        respond_to? hook and self.__send__(hook, action, passed_args, passed_options)
-      rescue => e
-        Puppet.warning("invoking #{action} #{type} hook: #{e}")
-      end
+      respond_to? hook and self.__send__(hook, action, passed_args, passed_options)
     end
   end
 
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
index 08bc0a3..464b2a7 100644
--- a/lib/puppet/interface/action.rb
+++ b/lib/puppet/interface/action.rb
@@ -239,7 +239,7 @@ WRAPPER
     end.select(&:required?).collect(&:name) - args.last.keys
 
     return if required.empty?
-    raise ArgumentError, "missing required options (#{required.join(', ')})"
+    raise ArgumentError, "The following options are required: #{required.join(', ')}"
   end
 
   ########################################################################
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
index 24826a6..23d0de4 100755
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
@@ -237,7 +237,7 @@ describe Puppet::Interface::Action do
           when_invoked { }
         end
       end
-      expect { face.bar }.to raise_error ArgumentError, /missing required options \(foo\)/
+      expect { face.bar }.to raise_error ArgumentError, /The following options are required: foo/
     end
 
     it "should fail when a required face option is not provided" do
@@ -245,7 +245,7 @@ describe Puppet::Interface::Action do
         option('--foo') { required }
         action(:bar) { when_invoked { } }
       end
-      expect { face.bar }.to raise_error ArgumentError, /missing required options \(foo\)/
+      expect { face.bar }.to raise_error ArgumentError, /The following options are required: foo/
     end
   end
 

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list