Exceptions in resources

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…

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...

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...

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.

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: Common Resource Functionality

--
Daniel DeLeo