Class: LogSanity::RoutingErrorCatcher

Inherits:
ActionDispatch::ShowExceptions
  • Object
show all
Defined in:
lib/log_sanity/middleware/routing_error_catcher.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/log_sanity/middleware/routing_error_catcher.rb', line 11

def call(env)
  request = ActionDispatch::Request.new env
  _, headers, body = response = @app.call(env)

  if headers['X-Cascade'] == 'pass'
    body.close if body.respond_to?(:close)
    raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
  end

  response
rescue ActionController::RoutingError => exception
  if request.show_exceptions?
    render_exception(request, exception)
  else
    raise exception
  end
end