Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 43 lines (34 sloc) 1.37 kB
acd5db3 @jeremy Rejig active support dependencies to behave better with the boot process
jeremy authored
1 require 'active_support/backtrace_cleaner'
2
f42c77f @dhh Added ActiveSupport::BacktraceCleaner and Rails::BacktraceCleaner for…
dhh authored
3 module Rails
4 class BacktraceCleaner < ActiveSupport::BacktraceCleaner
8ae9b05 @josevalim Make backtrace_cleaner work as expected. Prior to this patch, the Ful…
josevalim authored
5 APP_DIRS_PATTERN = /^\/?(app|config|lib|test)/
6 RENDER_TEMPLATE_PATTERN = /:in `_render_template_\w*'/
f42c77f @dhh Added ActiveSupport::BacktraceCleaner and Rails::BacktraceCleaner for…
dhh authored
7
8 def initialize
9 super
2110a52 Deprecate RAILS_ROOT in favor of Rails.root (which proxies to the app…
Carl Lerche authored
10 add_filter { |line| line.sub("#{Rails.root}/", '') }
8ae9b05 @josevalim Make backtrace_cleaner work as expected. Prior to this patch, the Ful…
josevalim authored
11 add_filter { |line| line.sub(RENDER_TEMPLATE_PATTERN, '') }
42b4407 @dhh Strip out the ./ part of the test path so the backtrace align perfectly
dhh authored
12 add_filter { |line| line.sub('./', '/') } # for tests
0da8e45 @al2o3cr Correctly clean backtraces from vendor/gems and gems in alternate ins…
al2o3cr authored
13
14 add_gem_filters
8ae9b05 @josevalim Make backtrace_cleaner work as expected. Prior to this patch, the Ful…
josevalim authored
15 add_silencer { |line| line !~ APP_DIRS_PATTERN }
f42c77f @dhh Added ActiveSupport::BacktraceCleaner and Rails::BacktraceCleaner for…
dhh authored
16 end
fa1926d @josh Exclude gem backtrace filter if rubygems is not loaded
josh authored
17
0da8e45 @al2o3cr Correctly clean backtraces from vendor/gems and gems in alternate ins…
al2o3cr authored
18 private
19 def add_gem_filters
8ae9b05 @josevalim Make backtrace_cleaner work as expected. Prior to this patch, the Ful…
josevalim authored
20 return unless defined?(Gem)
21
22 gems_paths = (Gem.path + [Gem.default_dir]).uniq.map!{ |p| Regexp.escape(p) }
23 return if gems_paths.empty?
24
21ff884 @fxn in regexps, the dot in a character class is not a metacharacter
fxn authored
25 gems_regexp = %r{(#{gems_paths.join('|')})/gems/([^/]+)-([\w.]+)/(.*)}
8ae9b05 @josevalim Make backtrace_cleaner work as expected. Prior to this patch, the Ful…
josevalim authored
26 add_filter { |line| line.sub(gems_regexp, '\2 (\3) \4') }
0da8e45 @al2o3cr Correctly clean backtraces from vendor/gems and gems in alternate ins…
al2o3cr authored
27 end
f42c77f @dhh Added ActiveSupport::BacktraceCleaner and Rails::BacktraceCleaner for…
dhh authored
28 end
29
30 # For installing the BacktraceCleaner in the test/unit
31 module BacktraceFilterForTestUnit #:nodoc:
32 def self.included(klass)
33 klass.send :alias_method_chain, :filter_backtrace, :cleaning
34 end
1f48c09 @Manfred Accept a prefix argument to filter_backtrace_with_cleaning [#1456 sta…
Manfred authored
35
36 def filter_backtrace_with_cleaning(backtrace, prefix=nil)
37 backtrace = filter_backtrace_without_cleaning(backtrace, prefix)
f42c77f @dhh Added ActiveSupport::BacktraceCleaner and Rails::BacktraceCleaner for…
dhh authored
38 backtrace = backtrace.first.split("\n") if backtrace.size == 1
39 Rails.backtrace_cleaner.clean(backtrace)
40 end
41 end
731dcd8 @josh Silence server backtrace in rescue templates and log files. Also remo…
josh authored
42 end
Something went wrong with that request. Please try again.