- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: graceful failure
- Date: Wed, 5 Feb 2014 15:36:45 -0800
`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
On Feb 5, 2014, at 2:41 PM, Josiah Kiehl <
">
> wrote:
I prefer:
Chef::Log.fatal!("Some message", 1) unless condition
On Wed, Feb 5, 2014 at 2:37 PM, James Kessler <
">
> wrote:
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.