diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2013-05-08 21:28:27 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2013-05-08 21:28:50 -0700 |
commit | 5e03239d59db7b21ceda576ce52b7fab3ad58c2d (patch) | |
tree | 8476799509da9af9ccf7d721f9101961e9e6a243 /actionpack/lib/action_dispatch | |
parent | c0df1e8c08a27a7de489dad7492015d68f2c76f7 (diff) | |
download | rails-5e03239d59db7b21ceda576ce52b7fab3ad58c2d.tar.gz rails-5e03239d59db7b21ceda576ce52b7fab3ad58c2d.tar.bz2 rails-5e03239d59db7b21ceda576ce52b7fab3ad58c2d.zip |
Fix that JSON and XML exception responses should give the HTTP error message for their status, by default, not the message from the underlying exception
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/public_exceptions.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb index 53bedaa40a..ebbf91d5c4 100644 --- a/actionpack/lib/action_dispatch/middleware/public_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/public_exceptions.rb @@ -11,7 +11,7 @@ module ActionDispatch status = env["PATH_INFO"][1..-1] request = ActionDispatch::Request.new(env) content_type = request.formats.first - body = { :status => status, :error => exception.message } + body = { :status => status, :error => Rack::Utils::HTTP_STATUS_CODES.fetch(status.to_i, Rack::Utils::HTTP_STATUS_CODES[500]) } render(status, content_type, body) end @@ -19,7 +19,7 @@ module ActionDispatch private def render(status, content_type, body) - format = content_type && "to_#{content_type.to_sym}" + format = "to_#{content_type.to_sym}" if content_type if format && body.respond_to?(format) render_format(status, content_type, body.public_send(format)) else |