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

Changeset 8835

Show
Ignore:
Timestamp:
02/10/08 01:08:05 (5 months ago)
Author:
nzkoz
Message:

2-0-stable: Precalculate the Backtrace of a template error to avoid raising exceptions in TemplateError#backtrace. These will abort the ruby vm. References #10936 [Aleksey Kondratenko]

Merging [8743]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/lib/action_view/template_error.rb

    r8210 r8835  
    1111        base_path, assigns.dup, source, original_exception 
    1212      @file_path = file_path 
     13      @backtrace = compute_backtrace 
    1314    end 
    1415 
     
    7374    end 
    7475 
     76    # don't do anything nontrivial here. Any raised exception from here becomes fatal 
     77    # (and can't be rescued). 
    7578    def backtrace 
    76       [ 
    77         "#{source_location.capitalize}\n\n#{source_extract(4)}\n    " + 
    78         clean_backtrace.join("\n    ") 
    79       ] 
     79      @backtrace 
    8080    end 
    8181 
    8282    private 
     83      def compute_backtrace 
     84        [ 
     85          "#{source_location.capitalize}\n\n#{source_extract(4)}\n    " + 
     86          clean_backtrace.join("\n    ") 
     87        ] 
     88      end 
     89 
    8390      def strip_base_path(path) 
    8491        stripped_path = File.expand_path(path).gsub(@base_path, "")