`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; endAnd then use it:raise SomeConditionNotMet, “additional detail about what a human does to fix the situation”HTH,--Daniel DeLeoOn Wednesday, February 5, 2014 at 2:42 PM, Noah Kantrowitz wrote:
Thats the same thing under the hood, so either is fine :-)--NoahOn Feb 5, 2014, at 2:41 PM, Josiah Kiehl < " target="_blank"> > wrote:I prefer:Chef::Log.fatal!("Some message", 1) unless conditionOn Wed, Feb 5, 2014 at 2:37 PM, James Kessler < " target="_blank"> > 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.