Module ActionController::Rescue
In: vendor/rails/actionpack/lib/action_controller/rescue.rb

Actions that fail to perform as expected throw exceptions. These exceptions can either be rescued for the public view (with a nice user-friendly explanation) or for the developers view (with tons of debugging information). The developers view is already implemented by the Action Controller, but the public view should be tailored to your specific application. So too could the decision on whether something is a public or a developer request.

You can tailor the rescuing behavior and appearance by overwriting the following two stub methods.

Methods

Protected Instance methods

Overwrite to expand the meaning of a local request in order to show local rescues on other occurences than the remote IP being 127.0.0.1. For example, this could include the IP of the developer machine when debugging remotely.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/rescue.rb, line 62
62:       def local_request? #:doc:
63:         @request.remote_addr == "127.0.0.1"
64:       end

Overwrite to implement custom logging of errors. By default logs as fatal.

[Source]

    # File vendor/rails/actionpack/lib/action_controller/rescue.rb, line 38
38:       def log_error(exception) #:doc:
39:         if ActionView::TemplateError === exception
40:           logger.fatal(exception.to_s)
41:         else
42:           logger.fatal(
43:             "\n\n#{exception.class} (#{exception.message}):\n    " + 
44:             clean_backtrace(exception).join("\n    ") + 
45:             "\n\n"
46:           )
47:         end
48:       end

Overwrite to implement public exception handling (for requests answering false to local_request?).

[Source]

    # File vendor/rails/actionpack/lib/action_controller/rescue.rb, line 51
51:       def rescue_action_in_public(exception) #:doc:
52:         case exception
53:           when RoutingError, UnknownAction then
54:             render_text(IO.read(File.join(RAILS_ROOT, 'public', '404.html')), "404 Not Found")
55:           else render_text "<html><body><h1>Application error (Rails)</h1></body></html>"
56:         end
57:       end

[Validate]