aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/exception.rb
blob: 5a2d21590bd6abf731b290d17409b22e4fa98031 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Exception
  
  alias :clean_message :message
  
  TraceSubstitutions = []
  
  def clean_backtrace
    backtrace.collect do |line|
      TraceSubstitutions.inject(line) do |line, (regexp, sub)|
        line.gsub regexp, sub
      end
    end
  end
  
  def application_backtrace
    before_application_frame = true
    
    clean_backtrace.reject do |line|
      non_app_frame = !! (line =~ /vendor|dispatch|ruby|script\/\w+/)
      before_application_frame = false unless non_app_frame
      non_app_frame && ! before_application_frame
    end
  end
end