Sha256: 02ed9b66070deefe2063b9322f572002e9625cfe0da1bc411dca6ac7080e41a3
Contents?: true
Size: 1.51 KB
Versions: 5
Compression:
Stored size: 1.51 KB
Contents
module Rollbar module Middleware module Rails module ShowExceptions include ExceptionReporter def render_exception_with_rollbar(env, exception) key = 'action_dispatch.show_detailed_exceptions' if exception.is_a?(ActionController::RoutingError) && env[key] scope = extract_scope_from(env) Rollbar.scoped(scope) do report_exception_to_rollbar(env, exception) end end render_exception_without_rollbar(env, exception) end def call_with_rollbar(env) call_without_rollbar(env) rescue ActionController::RoutingError => e # won't reach here if show_detailed_exceptions is true scope = extract_scope_from(env) Rollbar.scoped(scope) do report_exception_to_rollbar(env, e) end raise e end def extract_scope_from(env) scope = env['rollbar.scope'] unless scope Rollbar.log_warn( '[Rollbar] rollbar.scope key has been removed from Rack env.' ) end scope || {} end def self.included(base) base.send(:alias_method, :call_without_rollbar, :call) base.send(:alias_method, :call, :call_with_rollbar) base.send(:alias_method, :render_exception_without_rollbar, :render_exception) base.send(:alias_method, :render_exception, :render_exception_with_rollbar) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems