lib/rambulance/exceptions_app.rb in rambulance-1.1.1 vs lib/rambulance/exceptions_app.rb in rambulance-2.0.0

- old
+ new

@@ -7,10 +7,20 @@ # * are unassigned(427, 430, 509) # * is a joke definition(418) http_status >= 400 && ![418, 427, 430, 509].include?(http_status) end.invert + BAD_REQUEST_ERRORS = [ + ActionController::BadRequest, + begin + ActionDispatch::Http::Parameters::ParseError # Rails >= 5.2.0 + rescue NameError; end, + begin + ActionDispatch::ParamsParser::ParseError # Rails < 5.2.0 + rescue NameError; end, + ].compact.freeze + class ExceptionsApp < ActionController::Base layout :layout_name begin skip_forgery_protection @@ -67,10 +77,10 @@ request.env["MALFORMED_QUERY_STRING"], request.env["QUERY_STRING"] = request.env["QUERY_STRING"], "" end begin request.POST - rescue ActionController::BadRequest + rescue *BAD_REQUEST_ERRORS request.env["MALFORMED_BODY"], request.env["rack.input"] = request.env["rack.input"], StringIO.new end begin request.accepts