mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #17480 from gsamokovarov/exception-wrapper-traces
Move DebugExceptions#traces_from_wrapper to ExceptionWrapper
This commit is contained in:
commit
8602fc5e11
2 changed files with 23 additions and 29 deletions
|
@ -35,7 +35,7 @@ module ActionDispatch
|
||||||
|
|
||||||
if env['action_dispatch.show_detailed_exceptions']
|
if env['action_dispatch.show_detailed_exceptions']
|
||||||
request = Request.new(env)
|
request = Request.new(env)
|
||||||
traces = traces_from_wrapper(wrapper)
|
traces = wrapper.traces
|
||||||
|
|
||||||
trace_to_show = 'Application Trace'
|
trace_to_show = 'Application Trace'
|
||||||
if traces[trace_to_show].empty?
|
if traces[trace_to_show].empty?
|
||||||
|
@ -106,33 +106,5 @@ module ActionDispatch
|
||||||
ActionDispatch::Routing::RoutesInspector.new(@routes_app.routes.routes)
|
ActionDispatch::Routing::RoutesInspector.new(@routes_app.routes.routes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Augment the exception traces by providing ids for all unique stack frame
|
|
||||||
def traces_from_wrapper(wrapper)
|
|
||||||
application_trace = wrapper.application_trace
|
|
||||||
framework_trace = wrapper.framework_trace
|
|
||||||
full_trace = wrapper.full_trace
|
|
||||||
|
|
||||||
appplication_trace_with_ids = []
|
|
||||||
framework_trace_with_ids = []
|
|
||||||
full_trace_with_ids = []
|
|
||||||
|
|
||||||
if full_trace
|
|
||||||
full_trace.each_with_index do |trace, idx|
|
|
||||||
id_trace = {
|
|
||||||
id: idx,
|
|
||||||
trace: trace
|
|
||||||
}
|
|
||||||
appplication_trace_with_ids << id_trace if application_trace.include? trace
|
|
||||||
framework_trace_with_ids << id_trace if framework_trace.include? trace
|
|
||||||
full_trace_with_ids << id_trace
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{
|
|
||||||
"Application Trace" => appplication_trace_with_ids,
|
|
||||||
"Framework Trace" => framework_trace_with_ids,
|
|
||||||
"Full Trace" => full_trace_with_ids
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,6 +57,28 @@ module ActionDispatch
|
||||||
clean_backtrace(:all)
|
clean_backtrace(:all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def traces
|
||||||
|
appplication_trace_with_ids = []
|
||||||
|
framework_trace_with_ids = []
|
||||||
|
full_trace_with_ids = []
|
||||||
|
|
||||||
|
if full_trace
|
||||||
|
full_trace.each_with_index do |trace, idx|
|
||||||
|
trace_with_id = { id: idx, trace: trace }
|
||||||
|
|
||||||
|
appplication_trace_with_ids << trace_with_id if application_trace.include?(trace)
|
||||||
|
framework_trace_with_ids << trace_with_id if framework_trace.include?(trace)
|
||||||
|
full_trace_with_ids << trace_with_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{
|
||||||
|
"Application Trace" => appplication_trace_with_ids,
|
||||||
|
"Framework Trace" => framework_trace_with_ids,
|
||||||
|
"Full Trace" => full_trace_with_ids
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def self.status_code_for_exception(class_name)
|
def self.status_code_for_exception(class_name)
|
||||||
Rack::Utils.status_code(@@rescue_responses[class_name])
|
Rack::Utils.status_code(@@rescue_responses[class_name])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue