Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

do not lose backtrace information from the raised exception

  • Loading branch information...
commit facd3e87104b0b9bc1142471b76d7b0c80d7062e 1 parent 6033e8a
@tenderlove tenderlove authored
View
16 actionpack/lib/action_dispatch/http/request.rb
@@ -251,21 +251,17 @@ def session_options=(options)
# Override Rack's GET method to support indifferent access
def GET
- begin
- @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {})
- rescue TypeError => e
- raise ActionController::BadRequest, "Invalid query parameters: #{e.message}"
- end
+ @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {})
+ rescue TypeError => e
+ raise ActionController::BadRequest, "Invalid query parameters: #{e.message}", e.backtrace
end
alias :query_parameters :GET
# Override Rack's POST method to support indifferent access
def POST
- begin
- @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {})
- rescue TypeError => e
- raise ActionController::BadRequest, "Invalid request parameters: #{e.message}"
- end
+ @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {})
+ rescue TypeError => e
+ raise ActionController::BadRequest, "Invalid request parameters: #{e.message}", e.backtrace
end
alias :request_parameters :POST
View
9 actionpack/test/dispatch/request_test.rb
@@ -550,12 +550,13 @@ def url_for(options = {})
test "parameters still accessible after rack parse error" do
mock_rack_env = { "QUERY_STRING" => "x[y]=1&x[y][][w]=2", "rack.input" => "foo" }
request = nil
- begin
- request = stub_request(mock_rack_env)
- request.parameters
- rescue ActionController::BadRequest
+ request = stub_request(mock_rack_env)
+
+ assert_raises(ActionController::BadRequest) do
# rack will raise a TypeError when parsing this query string
+ request.parameters
end
+
assert_equal({}, request.parameters)
end
Please sign in to comment.
Something went wrong with that request. Please try again.