Module: Bugwatch::ControllerRescueHook

Defined in:
lib/bugwatch/controller_rescue_hook.rb

Instance Method Summary collapse

Instance Method Details

#rescue_with_handler(exception, **kwargs) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bugwatch/controller_rescue_hook.rb', line 3

def rescue_with_handler(exception, **kwargs)
  handler = super

  if handler && exception.is_a?(Exception) && !ReportedExceptions.reported?(exception)
    begin
      context = {
        handled:    true,
        controller: self.class.name,
        action:     (action_name if respond_to?(:action_name))
      }.compact

      Bugwatch.notify(exception, context: context)
    rescue StandardError
      # Never let reporting break the host's rescue flow
    end
  end

  handler
end