Skip to content
Browse files

do not lose backtrace information from the raised exception

  • Loading branch information...
1 parent 6033e8a commit facd3e87104b0b9bc1142471b76d7b0c80d7062e @tenderlove tenderlove committed
Showing with 11 additions and 14 deletions.
  1. +6 −10 actionpack/lib/action_dispatch/http/request.rb
  2. +5 −4 actionpack/test/dispatch/request_test.rb
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

0 comments on commit facd3e8

Please sign in to comment.
Something went wrong with that request. Please try again.