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:
parent
b75f5c278a
commit
d879c0ec5a
1 changed files with 9 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue