Sha256: c47f1ac8b22ae62474a7429b6d20eaa17396c3d5f4eef2988fcd10afdacbf30f
Contents?: true
Size: 1.49 KB
Versions: 4
Compression:
Stored size: 1.49 KB
Contents
require 'honeybadger/plugin' module Honeybadger module Plugins module Rails module ExceptionsCatcher # Internal: Adds additional Honeybadger info to Request env when an # exception is rendered in Rails' middleware. # # arg - The Rack env Hash in Rails 3.0-4.2. After Rails 5 arg is # an ActionDispatch::Request. # exception - The Exception which was rescued. # # Returns the super value of the middleware's #render_exception() # method. def render_exception(arg, exception) if arg.kind_of?(::ActionDispatch::Request) request = arg env = request.env else request = ::Rack::Request.new(arg) env = arg end env['honeybadger.exception'] = exception env['honeybadger.request.url'] = request.url rescue nil super(arg, exception) end end Plugin.register :rails_exceptions_catcher do requirement { defined?(::Rails.application) && ::Rails.application } execution do require 'rack/request' if defined?(::ActionDispatch::DebugExceptions) # Rails 3.2.x+ ::ActionDispatch::DebugExceptions.prepend(ExceptionsCatcher) elsif defined?(::ActionDispatch::ShowExceptions) # Rails 3.0.x and 3.1.x ::ActionDispatch::ShowExceptions.prepend(ExceptionsCatcher) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems