module ActionController #:nodoc: # 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. module Rescue def self.append_features(base) #:nodoc: super base.class_eval do alias_method :perform_action_without_rescue, :perform_action alias_method :perform_action, :perform_action_with_rescue end end protected # Exception handler called when the performance of an action raises an exception. def rescue_action(exception) log_error(exception) unless logger.nil? if consider_all_requests_local || local_request? rescue_action_locally(exception) else rescue_action_in_public(exception) end end # Overwrite to implement custom logging of errors. By default logs as fatal. def log_error(exception) #:doc: if ActionView::TemplateError === exception logger.fatal(exception.to_s) else logger.fatal( "\n\n#{exception.class} (#{exception.message}):\n " + clean_backtrace(exception).join("\n ") + "\n\n" ) end end # Overwrite to implement public exception handling (for requests answering false to local_request?). def rescue_action_in_public(exception) #:doc: render_text "