Forum: Ruby on Rails custom error pages-- which exceptions to catch?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
rafe (Guest)
on 2009-05-21 22:24
(Received via mailing list)
Hi all,

I implemented custom 404 and 500 error pages using rescue_from
according to an example I found at

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

  def render_500
    render :template => "errors/error_500", :layout =>
'singlecolumn', :status => 500

  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 }
    true  # so we can do "render_404 and return"

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.
This topic is locked and can not be replied to.