Module: Bugno::Middleware::ShowExceptions

Defined in:
lib/bugno/middleware/rails/show_exceptions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/bugno/middleware/rails/show_exceptions.rb', line 26

def self.included(base)
  base.send(:alias_method, :call_without_bugno, :call)
  base.send(:alias_method, :call, :call_with_bugno)

  base.send(:alias_method, :render_exception_without_bugno, :render_exception)
  base.send(:alias_method, :render_exception, :render_exception_with_bugno)
end

Instance Method Details

#call_with_bugno(env) ⇒ Object



16
17
18
19
20
# File 'lib/bugno/middleware/rails/show_exceptions.rb', line 16

def call_with_bugno(env)
  call_without_bugno(env)
rescue ActionController::RoutingError => e
  raise e
end

#extract_scope_from(env) ⇒ Object



22
23
24
# File 'lib/bugno/middleware/rails/show_exceptions.rb', line 22

def extract_scope_from(env)
  env.env
end

#render_exception_with_bugno(env, exception) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/bugno/middleware/rails/show_exceptions.rb', line 8

def render_exception_with_bugno(env, exception)
  if exception.is_a?(ActionController::RoutingError)
    Handler.call(exception: exception, env: extract_scope_from(env)) if Bugno.configured?
  end

  render_exception_without_bugno(env, exception)
end