Skip to content

Commit

Permalink
Defer creating Request object until the object is in need in the exce…
Browse files Browse the repository at this point in the history
…ptional case
  • Loading branch information
amatsuda committed Dec 15, 2022
1 parent 698f126 commit 41b3e61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -24,7 +24,6 @@ def initialize(app, routes_app = nil, response_format = :default, interceptors =
end

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

if headers["X-Cascade"] == "pass"
Expand All @@ -34,6 +33,7 @@ def call(env)

response
rescue Exception => exception
request = ActionDispatch::Request.new env
backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
wrapper = ExceptionWrapper.new(backtrace_cleaner, exception)

Expand Down
Expand Up @@ -22,9 +22,9 @@ def initialize(app, exceptions_app)
end

def call(env)
request = ActionDispatch::Request.new env
@app.call(env)
rescue Exception => exception
request = ActionDispatch::Request.new env
if request.show_exceptions?
render_exception(request, exception)
else
Expand Down

0 comments on commit 41b3e61

Please sign in to comment.