# ActiveRecord find exceptions

**URL:** <https://discuss.rubyonrails.org/t/activerecord-find-exceptions/6694>\
**Category:** rubyonrails-talk\
**Created:** [January 4, 2007, 1:19pm UTC](https://discuss.rubyonrails.org/t/activerecord-find-exceptions/6694 "2007-01-04T13:19:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anibal\_Rojas](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@Anibal\_Rojas](https://discuss.rubyonrails.org/u/Anibal_Rojas)\
**Post date:** [January 4, 2007, 1:19pm UTC](https://discuss.rubyonrails.org/t/activerecord-find-exceptions/6694/1 "2007-01-04T13:19:35Z")

</div>

Sebastian Delmont has an interesting solution for this situations, he posted it at his blog:

[http://www.notsostupid.com/blog/2006/06/28/do-or-do-not-or-maybe-try/](http://www.notsostupid.com/blog/2006/06/28/do-or-do-not-or-maybe-try/)

Currently offline, but you can checkit at googles cache:

[http://64.233.161.104/search?q=cache:4KIQLnwdpLYJ:www.notsostupid.com/blog/2006/06/28/do-or-do-not-or-maybe-try/+site:www.notsostupid.com+exception&hl=en&ct=clnk&cd=1&client=firefox](http://64.233.161.104/search?q=cache:4KIQLnwdpLYJ:www.notsostupid.com/blog/2006/06/28/do-or-do-not-or-maybe-try/+site:www.notsostupid.com+exception&hl=en&ct=clnk&cd=1&client=firefox)

Basically what you do is:

module Kernel &nbsp;&nbsp;# Returns 'value' in case of an exception, otherwise returns the execution &nbsp;&nbsp;# of the given block &nbsp;&nbsp;def try(value = nil) &nbsp;&nbsp;&nbsp;&nbsp;yield if block\_given? &nbsp;&nbsp;rescue Exception =\> exception &nbsp;&nbsp;&nbsp;&nbsp;value &nbsp;&nbsp;end end

Hope this simplies your exception handling for this situations
