public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Nicholas Seckar (author)
Tue Oct 18 07:06:34 -0700 2005
commit  60b6fac5deec3317acaca8dc3d399faea25223b2
tree    2c9628661e6286baad8f9f81ec81781da1a8c66e
parent  851dd0806be4e21f9a4fdcc77162711f46095bc5
rails / activesupport / lib / active_support / core_ext / exception.rb
100644 29 lines (23 sloc) 0.706 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Exception
  
  alias :clean_message :message
  
  TraceSubstitutions = []
  FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/
  
  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 =~ FrameworkRegexp)
      before_application_frame = false unless non_app_frame
      non_app_frame && ! before_application_frame
    end
  end
  
  def framework_backtrace
    clean_backtrace.select {|line| line =~ FrameworkRegexp}
  end
end