8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/show_json_exceptions.rb', line 8
def render_exception(env, exception)
log_error(exception)
exception = original_exception(exception)
request = ActionDispatch::Request.new(env)
exception_data = ["Exception: #{exception.message}"]
if @consider_all_requests_local || request.local?
exception_data << {backtrace: exception.backtrace}
end
render status_code(exception), {
successful: false,
result: {},
error_messages: exception_data
}.to_json
rescue Exception => failsafe_error
$stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}"
FAILSAFE_RESPONSE
end
|