aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/backtrace_cleaner.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-16 21:34:35 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-16 21:34:35 -0600
commiteb39d0f7b999f09c4e13f035634887a8f5592443 (patch)
tree4155dd1bb0cb878ff0aec9f36c113e4a094ab498 /activesupport/lib/active_support/backtrace_cleaner.rb
parentd2d4acf02793580e0f0c1bc380389527325b6254 (diff)
downloadrails-eb39d0f7b999f09c4e13f035634887a8f5592443.tar.gz
rails-eb39d0f7b999f09c4e13f035634887a8f5592443.tar.bz2
rails-eb39d0f7b999f09c4e13f035634887a8f5592443.zip
Use backtrace cleaner for dev mode exception page
Diffstat (limited to 'activesupport/lib/active_support/backtrace_cleaner.rb')
-rw-r--r--activesupport/lib/active_support/backtrace_cleaner.rb32
1 files changed, 24 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb
index 0e262c003e..6fab565646 100644
--- a/activesupport/lib/active_support/backtrace_cleaner.rb
+++ b/activesupport/lib/active_support/backtrace_cleaner.rb
@@ -9,7 +9,7 @@ module ActiveSupport
# Example:
#
# bc = BacktraceCleaner.new
- # bc.add_filter { |line| line.gsub(Rails.root, '') }
+ # bc.add_filter { |line| line.gsub(Rails.root, '') }
# bc.add_silencer { |line| line =~ /mongrel|rubygems/ }
# bc.clean(exception.backtrace) # will strip the Rails.root prefix and skip any lines from mongrel or rubygems
#
@@ -18,10 +18,19 @@ module ActiveSupport
def initialize
@filters, @silencers = [], []
end
-
+
# Returns the backtrace after all filters and silencers has been run against it. Filters run first, then silencers.
- def clean(backtrace)
- silence(filter(backtrace))
+ def clean(backtrace, kind = :silent)
+ filtered = filter(backtrace)
+
+ case kind
+ when :silent
+ silence(filtered)
+ when :noise
+ noise(filtered)
+ else
+ filtered
+ end
end
# Adds a filter from the block provided. Each line in the backtrace will be mapped against this filter.
@@ -51,21 +60,28 @@ module ActiveSupport
@silencers = []
end
-
private
def filter(backtrace)
@filters.each do |f|
backtrace = backtrace.map { |line| f.call(line) }
end
-
+
backtrace
end
-
+
def silence(backtrace)
@silencers.each do |s|
backtrace = backtrace.reject { |line| s.call(line) }
end
-
+
+ backtrace
+ end
+
+ def noise(backtrace)
+ @silencers.each do |s|
+ backtrace = backtrace.select { |line| s.call(line) }
+ end
+
backtrace
end
end