+1, although shouldn't those rescues rescue Exception, since  
Timeout::Error isn't descended from RuntimeError?

On Oct 20, 2009, at 11:42 AM, Markus Roberts wrote:

>
> If setup code for a process depends on network connectivity
> it needs do be protected with a rescue clause as much as the
> main body of the process.  There are many places where this
> _might_ be an issue, but in most cases it isn't in practice;
> this preliminary patch addesses the two cases where I have
> been able to confirm that it actually can cause the client
> daemon to exit.
>
> Signed-off-by: Markus Roberts <[email protected]>
> ---
> lib/puppet/configurer.rb |    7 ++++++-
> lib/puppet/ssl/host.rb   |    3 +--
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
> index efda545..9059ce2 100644
> --- a/lib/puppet/configurer.rb
> +++ b/lib/puppet/configurer.rb
> @@ -133,7 +133,12 @@ class Puppet::Configurer
>     # This just passes any options on to the catalog,
>     # which accepts :tags and :ignoreschedules.
>     def run(options = {})
> -        prepare()
> +        begin
> +            prepare()
> +        rescue => detail
> +            puts detail.backtrace if Puppet[:trace]
> +            Puppet.err "Failed to prepare catalog: %s" % detail
> +        end
>
>         if catalog = options[:catalog]
>             options.delete(:catalog)
> diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
> index 29b947e..debdeba 100644
> --- a/lib/puppet/ssl/host.rb
> +++ b/lib/puppet/ssl/host.rb
> @@ -235,10 +235,9 @@ class Puppet::SSL::Host
>
>     # Attempt to retrieve a cert, if we don't already have one.
>     def wait_for_cert(time)
> -        return if certificate
>         begin
> +            return if certificate
>             generate
> -
>             return if certificate
>         rescue StandardError => detail
>             Puppet.err "Could not request certificate: %s" %  
> detail.to_s
> -- 
> 1.6.4
>
>
> >


-- 
I don't deserve this award, but I have arthritis and I don't deserve
that either. -- Jack Benny
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to