Class: ActionDispatch::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/action_dispatch/middleware/executor.rb

Direct Known Subclasses

Reloader

Instance Method Summary collapse

Constructor Details

#initialize(app, executor) ⇒ Executor

Returns a new instance of Executor.


9
10
11
# File 'lib/action_dispatch/middleware/executor.rb', line 9

def initialize(app, executor)
  @app, @executor = app, executor
end

Instance Method Details

#call(env) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/action_dispatch/middleware/executor.rb', line 13

def call(env)
  state = @executor.run!(reset: true)
  begin
    response = @app.call(env)

    if env["action_dispatch.report_exception"]
      error = env["action_dispatch.exception"]
      @executor.error_reporter.report(error, handled: false, source: "application.action_dispatch")
    end

    returned = response << ::Rack::BodyProxy.new(response.pop) { state.complete! }
  rescue Exception => error
    request = ActionDispatch::Request.new env
    backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
    wrapper = ExceptionWrapper.new(backtrace_cleaner, error)
    @executor.error_reporter.report(wrapper.unwrapped_exception, handled: false, source: "application.action_dispatch")
    raise
  ensure
    state.complete! unless returned
  end
end