-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Expand file tree
/
Copy pathexecutor.rb
More file actions
45 lines (38 loc) · 1.27 KB
/
executor.rb
File metadata and controls
45 lines (38 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
# :markup: markdown
require "rack/body_proxy"
module ActionDispatch
class Executor
def initialize(app, executor)
@app, @executor = app, executor
end
def call(env)
state = @executor.run!(reset: true)
if response_finished = env["rack.response_finished"]
response_finished << proc { state.complete! }
end
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
unless response_finished
response << ::Rack::BodyProxy.new(response.pop) { state.complete! }
end
returned = true
response
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
if !returned && !response_finished
state.complete!
end
end
end
end
end