# Custom error pages-- which exceptions to catch?

**URL:** <https://www.ruby-forum.com/t/custom-error-pages-which-exceptions-to-catch/168520>\
**Category:** Rails\
**Created:** [May 21, 2009, 8:24pm UTC](https://www.ruby-forum.com/t/custom-error-pages-which-exceptions-to-catch/168520 "2009-05-21T20:24:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e495f1/32.png) [@rafe](https://www.ruby-forum.com/u/rafe)\
**Post date:** [May 21, 2009, 8:24pm UTC](https://www.ruby-forum.com/t/custom-error-pages-which-exceptions-to-catch/168520/1 "2009-05-21T20:24:27Z")

</div>

Hi all,

I implemented custom 404 and 500 error pages using rescue\_from  
according to an example I found at  
[http://blog.ubrio.us/code/rails-22-custom-error-pages-with-exception-loggable/](http://blog.ubrio.us/code/rails-22-custom-error-pages-with-exception-loggable/)

Here’s my version:

unless ActionController::Base.consider\_all\_requests\_local  
rescue\_from ActiveRecord::RecordNotFound,  
ActionController::RoutingError, ActionController::UnknownController,  
ActionController::UnknownAction, :with =\> :render\_404  
rescue\_from RuntimeError, :with =\> :render\_500  
end

def render\_500  
render :template =\> “errors/error\_500”, :layout =\>  
‘singlecolumn’, :status =\> 500  
end

def render\_404  
respond\_to do |type|  
type.html { render :template =\> “errors/error\_404”, :layout =\>  
‘singlecolumn’, :status =\> 404 }  
type.all { render :nothing =\> true, :status =\> 404 }  
end  
true # so we can do “render\_404 and return”  
end

Then I went to test it, by sticking a call to the undefined name  
“foobar” at the top of my homepage action. This raised a NameError,  
which wasn’t caught by my 500 error catcher. Now, I can just add the  
error to the list, but I’m curious about other exceptions that could  
be raised that I haven’t anticipated. When implementing custom error  
pages, which exceptions do folks like to catch?

Rafe R.  
Common Media, Inc.

> **[Welcome — Common Media](https://commonmedia.com/)**
>
> Western Massachusetts WordPress and Drupal studio: UX design, website development, maintenance, accessibility and D8 migration.
