-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Call #after of middleware on error #1240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,12 @@ def call(env) | |
def call!(env) | ||
@env = env | ||
before | ||
@app_response = @app.call(@env) | ||
after || @app_response | ||
begin | ||
@app_response = @app.call(@env) | ||
ensure | ||
after_response = after | ||
end | ||
after_response || @app_response | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either all the paths aren't covered by specs or this can be: begin
@app_response = @app.call(@env)
ensure
after || @app_response
end Causes the after middleware to execute on error, and raises the exception as before. What am I missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we shouldn't be expecting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... wait. Looks like the old behavior was to use the response. So let me take this back, we should preserve the response if it was there. I guess it should be closer to this: begin
@app_response = @app.call(@env)
ensure
@after_response = after
end
@after_response || @app_response There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, thanks. |
||
|
||
# @abstract | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ def before | |
end | ||
|
||
def after | ||
return unless @app_response | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the semantics of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Raised an exception if your suggestion is reflect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, this is right, leave it here. |
||
status, headers, bodies = *@app_response | ||
|
||
if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be under >= 0.15.0 and increment the version in version.rb to 0.15.0 as well, now that we have a major change.