Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2654

Show
Ignore:
Timestamp:
10/16/05 17:47:19 (3 years ago)
Author:
ulysses
Message:

Update Exception extension to show the first few framework frames in an application trace.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r2623 r2654  
    11*SVN* 
    22 
    3 * Added Extension extension to provide support for clean backtraces. [Nicholas Seckar] 
     3* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar]  
     4 
     5* Added Exception extension to provide support for clean backtraces. [Nicholas Seckar] 
    46 
    57* Updated whiny nil to be more concise and useful. [Nicholas Seckar] 
  • trunk/activesupport/lib/active_support/core_ext/exception.rb

    r2623 r2654  
    1414   
    1515  def application_backtrace 
    16     clean_backtrace.reject { |line| line =~ /(vendor|dispatch|ruby|script\/\w+)/ } 
     16    before_application_frame = true 
     17     
     18    clean_backtrace.reject do |line| 
     19      non_app_frame = !! (line =~ /vendor|dispatch|ruby|script\/\w+/) 
     20      before_application_frame = false unless non_app_frame 
     21      non_app_frame && ! before_application_frame 
     22    end 
    1723  end 
    1824end 
  • trunk/activesupport/test/core_ext/exception_test.rb

    r2646 r2654  
    2222  end 
    2323   
     24  def test_app_backtrace 
     25    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     26    e = get_exception RuntimeError, 'RAWR', ['bhal.rb', ' vendor/file.rb some stuff', 'almost all'] 
     27    assert_kind_of Exception, e 
     28    assert_equal ['bhal.rb', 'almost all'], e.application_backtrace 
     29  end 
     30   
     31  def test_app_backtrace_with_before 
     32    Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 
     33    e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'bhal.rb', ' vendor/file.rb some stuff', 'almost all'] 
     34    assert_kind_of Exception, e 
     35    assert_equal ['vendor/file.rb some stuff', 'bhal.rb', 'almost all'], e.application_backtrace 
     36  end 
     37   
    2438end