# Exception Handlers with ignore\_failure

**URL:** <https://discourse.chef.io/t/exception-handlers-with-ignore-failure/3406>\
**Category:** Chef Infra (archive)\
**Created:** [December 4, 2012, 12:00am UTC](https://discourse.chef.io/t/exception-handlers-with-ignore-failure/3406 "2012-12-04T00:00:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfotop](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jfotop](https://discourse.chef.io/u/jfotop)\
**Post date:** [December 4, 2012, 12:00am UTC](https://discourse.chef.io/t/exception-handlers-with-ignore-failure/3406/1 "2012-12-04T00:00:55Z")

</div>

The following question may be plain dumb, but since I’m not afraid to be called  
dumb, I’m going to ask 😛

Is there anyway to use exception handlers on a chef run and get an email (like  
the one in [http://docs.opscode.com/essentials\_handlers\_write.html](http://docs.opscode.com/essentials_handlers_write.html)) if a  
resource that has “ignore\_failure -\> true” ?  
I want to configure chef to continue it’s run even if some resources fail, but  
get notified via email if any resource failed and only if there was a failure.  
I’ll say it also in another way:

- If resource with ignore\_failure-\>true fails, continue run but send an email.
- If resource with ignore\_failure-\>false fails, exit chef run and send an  
email.
- If nothing fails, don’t send an email…

Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![Kallen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallen/32/1049_2.png) [@Kallen](https://discourse.chef.io/u/Kallen)\
**Post date:** [December 4, 2012, 12:13am UTC](https://discourse.chef.io/t/exception-handlers-with-ignore-failure/3406/2 "2012-12-04T00:13:14Z")

</div>

totally not dumb, imo. lookin' forward to readin' feedback.

kallen

On Mon, 03 Dec 2012, jfotop wrote:

> The following question may be plain dumb, but since I'm not afraid to be called  
> dumb, I'm going to ask 😛
> 
> Is there anyway to use exception handlers on a chef run and get an email (like  
> the one in [http://docs.opscode.com/essentials\_handlers\_write.html](http://docs.opscode.com/essentials_handlers_write.html)) if a  
> resource that has "ignore\_failure -\> true" ?  
> I want to configure chef to continue it's run even if some resources fail, but  
> get notified via email if any resource failed and only if there was a failure.  
> I'll say it also in another way:
> 
> - If resource with ignore\_failure-\>true fails, continue run but send an email.
> - If resource with ignore\_failure-\>false fails, exit chef run and send an  
> email.
> - If nothing fails, don't send an email...
> 
> Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![vasdevneha](https://avatars.discourse-cdn.com/v4/letter/v/58956e/32.png) [@vasdevneha](https://discourse.chef.io/u/vasdevneha)\
**Post date:** [October 30, 2017, 7:18am UTC](https://discourse.chef.io/t/exception-handlers-with-ignore-failure/3406/3 "2017-10-30T07:18:40Z")

</div>

U can use chef\_handlers to send a mail.

Chef.event\_handler do  
on :resource\_failed do  
HandlerSendEmail::Helper.new.send\_email\_on\_run\_failure(  
Chef.run\_context.node.name  
)  
end  
end  
something like this u can use
