# Unrecoverable exception handling

**URL:** <https://www.ruby-forum.com/t/unrecoverable-exception-handling/129851>\
**Category:** Rails\
**Created:** [February 22, 2008, 1:59am UTC](https://www.ruby-forum.com/t/unrecoverable-exception-handling/129851 "2008-02-22T01:59:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [February 22, 2008, 1:59am UTC](https://www.ruby-forum.com/t/unrecoverable-exception-handling/129851/1 "2008-02-22T01:59:46Z")

</div>

Hi,

I asked this question on [railsforum.com](http://railsforum.com) but nobody replied yet. I  
wanted to know how new recoverable and unrecoverable exceptions should  
be handled.

Unrecoverable exceptions for standard CRUD operations render the 500  
page. What if I write a new set of actions that might generate an  
exception? Should I wrap the whole action into a ‘begin-rescue  
Exception’ block and display a flash warning to the user, or is it the  
Rails way to let it be rescued by the base action controller which  
displays the 500 page?

The recoverable exceptions are more straight forward. Code which  
raises these errors should be wrapped in ‘begin-rescue MyException’  
blocks, and then displayed as a warning to the users, right?

Thanks,  
Tiberiu

---

<div class="post-metadata">

**Author:** ![mr\_tibs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mr\_tibs](https://www.ruby-forum.com/u/mr_tibs)\
**Post date:** [February 22, 2008, 11:28am UTC](https://www.ruby-forum.com/t/unrecoverable-exception-handling/129851/2 "2008-02-22T11:28:26Z")

</div>

On 22 Feb 2008, at 00:59, Mr\_Tibs wrote:

> Exception’ block and display a flash warning to the user, or is it the  
> Rails way to let it be rescued by the base action controller which  
> displays the 500 page?
> 
> The recoverable exceptions are more straight forward. Code which  
> raises these errors should be wrapped in ‘begin-rescue MyException’  
> blocks, and then displayed as a warning to the users, right?

in 2.0 in the controller you can stick

rescue\_from SomeException, SomeOtherException, :with  
=\> :some\_error\_handler

def some\_error\_handler(exception)  
#do something appropriate (eg display message to use)  
end

in your controller, to commonalizer things like displaying an error  
message

Fred
