# Skipping rescue handlers in dev mode

**URL:** <https://www.ruby-forum.com/t/skipping-rescue-handlers-in-dev-mode/182428>\
**Category:** Rails\
**Created:** [January 27, 2010, 10:07pm UTC](https://www.ruby-forum.com/t/skipping-rescue-handlers-in-dev-mode/182428 "2010-01-27T22:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tristan](https://www.ruby-forum.com/u/tristan)\
**Post date:** [January 27, 2010, 10:07pm UTC](https://www.ruby-forum.com/t/skipping-rescue-handlers-in-dev-mode/182428/1 "2010-01-27T22:07:56Z")

</div>

Hi all

To make my error pages more user-friendly I’m rendering my error  
messages (404, 500 etc) using the site’s layout. To do this I’m using  
rescue\_from as below:

rescue\_from Exception, :with =\> :server\_error  
rescue\_from ActionController::RoutingError,  
ActiveRecord::RecordNotFound, :with =\> :not\_found\_error

private

def server\_error(exception)  
activate\_authlogic  
render :template =\> ‘common/500’, :status =\> 500  
end

def not\_found\_error(exception)  
activate\_authlogic  
render :template =\> ‘common/404’, :status =\> 404  
end

Obviously not as DRY as it could be but I’m really just experimenting  
right now. Also, not completely happy with having to call  
activate\_authlogic but it’s a necessary evil.

I’d like to be able to totally bypass these handlers when I’m in dev  
mode and have the regular stack trace appear. Anyone have ideas about  
how I could do this cleanly without having to resort to checking  
consider\_all\_requests\_local and local\_request??

Also, I realise that some exceptions might occur before this code can  
be run. Any ideas on how this code might behave in that situation?

Thanks  
Tristan

---

<div class="post-metadata">

**Author:** ![tristan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tristan](https://www.ruby-forum.com/u/tristan)\
**Post date:** [February 5, 2010, 9:21am UTC](https://www.ruby-forum.com/t/skipping-rescue-handlers-in-dev-mode/182428/2 "2010-02-05T09:21:10Z")

</div>

try this  
unless ActionController::Base.consider\_all\_requests\_local  
rescue\_from Exception, :with =\> :server\_error  
rescue\_from ActionController::RoutingError,  
ActiveRecord::RecordNotFound, :with =\> :not\_found\_error  
end

You’ll notice in config/development.rb you set  
consider\_all\_requests\_local to true
