[chef] Re: Re: Re: Re: graceful failure


Chronological Thread 
  • From: Sölvi Páll Ásgeirsson < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: graceful failure
  • Date: Thu, 6 Feb 2014 11:32:29 +0000

+1 for raise.

For bonus points, if you're using an exception handler to, for example send emails, you will get the actual error in your e-mail, instead of just 'SystemExit'.

regards,
Sölvi


On Wed, Feb 5, 2014 at 11:36 PM, Daniel DeLeo < " target="_blank"> > wrote:
`raise` is better. The various `fatal!` methods in Chef aren’t intended to halt a Chef run, and they call `exit` which raises a SystemExit exception. Depending on where you do this, chef-client may actually exit when not intended. For bonus points, you can define a custom error class with code like:

  class SomeConditionNotMet < StandardError; end

And then use it:

  raise SomeConditionNotMet, “additional detail about what a human does to fix the situation”

HTH,

-- 
Daniel DeLeo

On Wednesday, February 5, 2014 at 2:42 PM, Noah Kantrowitz wrote:

Thats the same thing under the hood, so either is fine :-)

--Noah


I prefer:

Chef::Log.fatal!("Some message", 1) unless condition


Hi,

What's the best way to gracefully fail a recipe? Currently I'm doing something like "raise 'some error' unless foo"

Thanks,
-James





Archive powered by MHonArc 2.6.16.

§