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

Changeset 250

Show
Ignore:
Timestamp:
12/22/04 13:44:16 (4 years ago)
Author:
david
Message:

Added more informative exception when using helper :some_helper and the helper requires another file that fails, you'll get an error message tells you what file actually failed to load, rather than falling back on assuming it was the helper file itself #346 [dblack]

Files:

Legend:

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

    r239 r250  
    11*SVN* 
     2 
     3* Added more informative exception when using helper :some_helper and the helper requires another file that fails, you'll get an 
     4  error message tells you what file actually failed to load, rather than falling back on assuming it was the helper file itself #346 [dblack] 
    25 
    36* Fixed regression with Base#reset_session that wouldn't use the the DEFAULT_SESSION_OPTIONS [adam@the-kramers.net] 
  • trunk/actionpack/lib/action_controller/helpers.rb

    r194 r250  
    5656            begin 
    5757              require_dependency(file_name) 
    58             rescue LoadError 
    59               raise LoadError, "Missing helper file helpers/#{file_name}.rb" 
     58            rescue LoadError => load_error 
     59              requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] 
     60              if requiree == file_name 
     61                raise LoadError, "Missing helper file helpers/#{file_name}.rb" 
     62              else 
     63                raise LoadError, "Can't load file: #{requiree}" 
     64              end 
    6065            end 
    6166            raise ArgumentError, "Missing #{class_name} module in helpers/#{file_name}.rb" unless Object.const_defined?(class_name) 
  • trunk/actionpack/test/controller/helper_test.rb

    r4 r250  
    7171  end 
    7272 
     73  def test_declare_missing_file_from_helper 
     74    require 'broken_helper' 
     75    rescue LoadError => e 
     76      assert_nil /\bbroken_helper\b/.match(e.to_s)[1] 
     77  end 
     78 
    7379  def test_helper_block 
    7480    assert_nothing_raised {