1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Minor cleanup in AD::DebugExceptions

This commit is contained in:
Jorge Bejar 2015-07-07 13:41:04 -03:00
parent b75f5c278a
commit d879c0ec5a

View file

@ -93,24 +93,27 @@ module ActionDispatch
def render_for_api_application(request, wrapper)
body = {
status: wrapper.status_code,
error: Rack::Utils::HTTP_STATUS_CODES.fetch(wrapper.status_code, Rack::Utils::HTTP_STATUS_CODES[500]),
status: wrapper.status_code,
error: Rack::Utils::HTTP_STATUS_CODES.fetch(
wrapper.status_code,
Rack::Utils::HTTP_STATUS_CODES[500]
),
exception: wrapper.exception.inspect,
traces: wrapper.traces
traces: wrapper.traces
}
content_type = request.formats.first
to_format = "to_#{content_type.to_sym}"
if content_type && body.respond_to?(to_format)
body = body.public_send(to_format)
formatted_body = body.public_send(to_format)
format = content_type
else
body = body.to_json
formatted_body = body.to_json
format = Mime::JSON
end
render(wrapper.status_code, body, format)
render(wrapper.status_code, formatted_body, format)
end
def create_template(request, wrapper)