mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
lib/irb.rb: simplified backtrace filtering
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
13247fa417
commit
43e64b8585
1 changed files with 11 additions and 18 deletions
25
lib/irb.rb
25
lib/irb.rb
|
@ -508,31 +508,24 @@ module IRB
|
||||||
lasts = []
|
lasts = []
|
||||||
levels = 0
|
levels = 0
|
||||||
if exc.backtrace
|
if exc.backtrace
|
||||||
filtered_line_count = 0
|
count = 0
|
||||||
exc.backtrace.each_with_index do |m, i|
|
exc.backtrace.each do |m|
|
||||||
num_str = (i + 1 - filtered_line_count).to_s.rjust(9, ' ')
|
m = @context.workspace.filter_backtrace(m) or next unless irb_bug
|
||||||
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
m = sprintf("%9d: from %s", (count += 1), m)
|
||||||
if m
|
|
||||||
if messages.size < @context.back_trace_limit
|
if messages.size < @context.back_trace_limit
|
||||||
messages.push "#{num_str}: from "+m
|
messages.push(m)
|
||||||
else
|
elsif lasts.size < @context.back_trace_limit
|
||||||
lasts.push "#{num_str}: from "+m
|
lasts.push(m).shift
|
||||||
if lasts.size > @context.back_trace_limit
|
|
||||||
lasts.shift
|
|
||||||
levels += 1
|
levels += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
filtered_line_count += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
print "Traceback (most recent call last):\n"
|
print "Traceback (most recent call last):\n"
|
||||||
unless lasts.empty?
|
unless lasts.empty?
|
||||||
print lasts.reverse.join("\n"), "\n"
|
puts lasts.reverse
|
||||||
printf "... %d levels...\n", levels if levels > 0
|
printf "... %d levels...\n", levels if levels > 0
|
||||||
end
|
end
|
||||||
print messages.reverse.join("\n"), "\n"
|
puts messages.reverse
|
||||||
print exc.class, ": ", exc, "\n"
|
print exc.class, ": ", exc, "\n"
|
||||||
print "Maybe IRB bug!\n" if irb_bug
|
print "Maybe IRB bug!\n" if irb_bug
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue