Tuesday, 20 August 2013

How to capture Chef exceptions

How to capture Chef exceptions

I'm working on a Chef recipe right now and I need to update a databag with
some information depending on the result of a code. Basically I need to
update a databag with succeed or failed. The code looks like this:
begin
some code executed
rescue
Update data bag: failed
else
Update data bag: succeed
end
The problem is that even though there is an error like a missing file, the
excecution goes directly to the "else" block and updates the data bag as
"succeed". What I am missing here? Any kind of help with be much
appreciated. Thanks.

No comments:

Post a Comment