Module

Rescue

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.

The default behavior for public exceptions is to render a static html file with the name of the error code thrown. If no such file exists, an empty response is sent with the correct status code.

You can override what constitutes a local request by overriding the local_request? method in your own controller. Custom rescue behavior is achieved by overriding the rescue_action_in_public and rescue_action_locally methods.

Modules
ClassMethods
Constants
DEFAULT_RESCUE_RESPONSE
DEFAULT_RESCUE_RESPONSES
DEFAULT_RESCUE_TEMPLATE
DEFAULT_RESCUE_TEMPLATES
LOCALHOST
Public Methods
included
Protected Methods
local_request? True if the request came from localhost, 127.0.0.1. Override this method if you wish to redefine the meaning of a local request to include remote IP addresses or other criteria.
log_error Overwrite to implement custom logging of errors. By default logs as fatal.
render_optional_error_file Attempts to render a static error page based on the status_code thrown, or just return headers if no such file exists. For example, if a 500 error is being handled Rails will first attempt to render the file at public/500.html. If the file doesn’t exist, the body of the response will be left empty.
rescue_action Exception handler called when the performance of an action raises an exception.
rescue_action_in_public Overwrite to implement public exception handling (for requests answering false to local_request?). By default will call render_optional_error_file. Override this method to provide more user friendly error messages.s
rescue_action_locally Render detailed diagnostics for unhandled exceptions rescued from a controller action.
rescue_action_with_handler Tries to rescue the exception by looking up and calling a registered handler.
Private Methods
clean_backtrace
handler_for_rescue
perform_action_with_rescue
rescues_path
response_code_for_rescue
template_path_for_local_rescue
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.