class LogSanity::RoutingErrorCatcher

Public Instance Methods

call(env) click to toggle source
# 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