| In: |
vendor/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.
Overwrite to implement custom logging of errors. By default logs as fatal.
# File vendor/actionpack/lib/action_controller/rescue.rb, line 30
30: def log_error(exception) #:doc:
31: logger.fatal(
32: " #{exception.class} (#{exception.message}):\n " +
33: clean_backtrace(exception).join("\n ") +
34: "\n"
35: )
36: end
Overwrite to implement public exception handling (for requests answering false to local_request?).
# File vendor/actionpack/lib/action_controller/rescue.rb, line 39
39: def rescue_action_in_public(exception) #:doc:
40: render_text "<html><body><h1>Application error (Rails)</h1></body></html>"
41: end
Overwrite to expand the meaning of a local request in order to show local rescues on other occurances than the remote IP being 127.0.0.1. For example, this include the IP of the developer machine when debugging remotely.
# File vendor/actionpack/lib/action_controller/rescue.rb, line 46
46: def local_request? #:doc:
47: @request.remote_addr == "127.0.0.1"
48: end