Exceptions in resources


#1

I just asked a question about which exceptions to rescue when using
http_request. After
doing some more research, I’ve learned that this question doesn’t really make
sense…

I’ve read that I can’t catch the Exception at the time the recipe runs.

I have some code that uses Net::HTTP::Get that runs in a lwrp. I am
able to rescue exceptions
there. Must I write my own code to do an HTTP post if I need to have
the run not
fail just because it can’t post? The post is ideal, but optional…


#2

Brief answer: no, you can use ignore_failure in any resource to continue the chef run if it fails.

Side option the retry_count (I think) attribute to let a resource retry its job in case of failure.

The doc about it is somewhere in the common options in docs.getchef.Com, but on the phone I can’t tell right now

---- John de la Garza a écrit ----

I just asked a question about which exceptions to rescue when using
http_request. After
doing some more research, I’ve learned that this question doesn’t really make
sense…

I’ve read that I can’t catch the Exception at the time the recipe runs.

I have some code that uses Net::HTTP::Get that runs in a lwrp. I am
able to rescue exceptions
there. Must I write my own code to do an HTTP post if I need to have
the run not
fail just because it can’t post? The post is ideal, but optional…


#3

Can you back up and explain what you are trying to do?

–Noah

On Oct 14, 2014, at 11:34 AM, John de la Garza john.garza@rallyhealth.com wrote:

I just asked a question about which exceptions to rescue when using
http_request. After
doing some more research, I’ve learned that this question doesn’t really make
sense…

I’ve read that I can’t catch the Exception at the time the recipe runs.

I have some code that uses Net::HTTP::Get that runs in a lwrp. I am
able to rescue exceptions
there. Must I write my own code to do an HTTP post if I need to have
the run not
fail just because it can’t post? The post is ideal, but optional…


#4

On Tue, Oct 14, 2014 at 2:42 PM, Noah Kantrowitz noah@coderanger.net wrote:

Can you back up and explain what you are trying to do?

–Noah

I have a recipe that does a http_request to post to a REST api. If
that api is down I don’t want
the entire run to fail, I just want a log entry and for the run continue.


#5

On Tuesday, October 14, 2014 at 8:31 PM, John de la Garza wrote:

On Tue, Oct 14, 2014 at 2:42 PM, Noah Kantrowitz <noah@coderanger.net (mailto:noah@coderanger.net)> wrote:

Can you back up and explain what you are trying to do?

–Noah

I have a recipe that does a http_request to post to a REST api. If
that api is down I don’t want
the entire run to fail, I just want a log entry and for the run continue.

Look at ignore_failure here: http://docs.getchef.com/resource_common.html


Daniel DeLeo