2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-05-15 20:49:11 -04:00
|
|
|
module ActionController #:nodoc:
|
2017-08-26 02:30:39 -04:00
|
|
|
# This module is responsible for providing +rescue_from+ helpers
|
2016-04-28 15:18:05 -04:00
|
|
|
# to controllers and configuring when detailed exceptions must be
|
2011-12-16 04:38:17 -05:00
|
|
|
# shown.
|
2009-05-15 20:49:11 -04:00
|
|
|
module Rescue
|
2009-05-28 12:35:36 -04:00
|
|
|
extend ActiveSupport::Concern
|
2009-09-15 11:05:46 -04:00
|
|
|
include ActiveSupport::Rescuable
|
2009-05-15 20:49:11 -04:00
|
|
|
|
2011-12-16 04:38:17 -05:00
|
|
|
# Override this method if you want to customize when detailed
|
|
|
|
# exceptions must be shown. This method is only called when
|
2017-08-26 02:30:39 -04:00
|
|
|
# +consider_all_requests_local+ is +false+. By default, it returns
|
|
|
|
# +false+, but someone may set it to <tt>request.local?</tt> so local
|
2017-03-11 08:17:44 -05:00
|
|
|
# requests in production still show the detailed exception pages.
|
2011-11-22 05:34:13 -05:00
|
|
|
def show_detailed_exceptions?
|
2011-12-16 04:38:17 -05:00
|
|
|
false
|
2011-11-22 05:34:13 -05:00
|
|
|
end
|
|
|
|
|
2009-05-28 10:49:02 -04:00
|
|
|
private
|
2019-07-31 04:26:43 -04:00
|
|
|
def process_action(*)
|
2009-05-28 10:49:02 -04:00
|
|
|
super
|
|
|
|
rescue Exception => exception
|
2016-08-06 12:51:43 -04:00
|
|
|
request.env["action_dispatch.show_detailed_exceptions"] ||= show_detailed_exceptions?
|
2016-05-13 20:43:48 -04:00
|
|
|
rescue_with_handler(exception) || raise
|
2009-05-28 10:49:02 -04:00
|
|
|
end
|
2009-05-15 20:49:11 -04:00
|
|
|
end
|
|
|
|
end
|