Skip to content

Commit

Permalink
Correctly initialize ExceptionWrapper for Rails >= 5.0
Browse files Browse the repository at this point in the history
Starting with
rails/rails@6d85804
the ActionDispatch::ExceptionWrapper class gets the BacktraceCleaner
object from the env directly rather than extracting it internally from
the env Hash. We need to handle both interfaces here.
  • Loading branch information
meineerde committed May 18, 2020
1 parent 0a7b1ca commit 0993fb6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/rackstash/log_subscriber.rb
Expand Up @@ -21,9 +21,15 @@ def redirect_to(event)
end

def _extract_exception_backtrace(env)
return unless env['action_dispatch.exception']
exception = env['action_dispatch.exception']
return unless exception

exception_wrapper = ActionDispatch::ExceptionWrapper.new(env, env['action_dispatch.exception'])
if ActionPack.version < Gem::Version.new('5.0')
exception_wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)
else
backtrace_cleaner = env['action_dispatch.backtrace_cleaner']
exception_wrapper = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception)
end
data = {
:error_backtrace => exception_wrapper.full_trace.join("\n")
}
Expand Down

0 comments on commit 0993fb6

Please sign in to comment.