diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-06-14 09:01:43 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-06-14 09:01:58 -0700 |
commit | 99c9d18601539c7e7e87f26bb047add1f93072af (patch) | |
tree | 9ccc6d6cbaa24dd765569e58b2ffecc60f30979f | |
parent | f278b067891b3a3e3462e92ada72e8dc5f24797b (diff) | |
download | rails-99c9d18601539c7e7e87f26bb047add1f93072af.tar.gz rails-99c9d18601539c7e7e87f26bb047add1f93072af.tar.bz2 rails-99c9d18601539c7e7e87f26bb047add1f93072af.zip |
Wrap up missing helper exceptions
The `path` method on missing helper errors is inconsistent with the
implementation on LoadError in Ruby 2.0. Wrap up the missing helper
exceptions so that the inconsistent behavior is mirrored in Ruby 2.0
(until we can figure out *why* it's inconsistent).
-rw-r--r-- | actionpack/lib/abstract_controller/helpers.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 772af86770..c36b210e23 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -135,8 +135,7 @@ module AbstractController begin require_dependency(file_name) rescue LoadError => e - e.instance_variable_set(:@path, "helpers/#{e.path}") - raise + raise MissingHelperError.new(e, file_name) end file_name.camelize.constantize when Module @@ -147,6 +146,15 @@ module AbstractController end end + class MissingHelperError < LoadError + def initialize(error, path) + @error = error + @path = "helpers/#{path}.rb" + set_backtrace error.backtrace + super("Missing helper file helpers/%s.rb" % error) + end + end + private # Makes all the (instance) methods in the helper module available to templates # rendered through this controller. |