Skip to content

Commit

Permalink
Fix ActionDispatchSpy#render_exception for Rails 7.1 (#1423)
Browse files Browse the repository at this point in the history
In Rails 7.1 `render_exception` was changed to take an ActionDispatch::ExceptionWrapper instead of an Exception. I've added support for the new way while keeping support for pre 7.1.
  • Loading branch information
jclusso authored Nov 24, 2023
1 parent 572058c commit 9612945
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/elastic_apm/spies/action_dispatch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ module Spies
class ActionDispatchSpy
# @api private
module Ext
def render_exception(env, exception)
context = ElasticAPM.build_context(rack_env: env, for_type: :error)
def render_exception(request, exception_or_wrapper)
context = ElasticAPM.build_context(
rack_env: request, for_type: :error
)
exception =
if exception_or_wrapper.is_a?(ActionDispatch::ExceptionWrapper)
exception_or_wrapper.exception
else
exception_or_wrapper
end
ElasticAPM.report(exception, context: context, handled: false)

super(env, exception)
super(request, exception_or_wrapper)
end
end

Expand Down

0 comments on commit 9612945

Please sign in to comment.