From 99c9d18601539c7e7e87f26bb047add1f93072af Mon Sep 17 00:00:00 2001 From: Aaron Patterson <aaron.patterson@gmail.com> Date: Thu, 14 Jun 2012 09:01:43 -0700 Subject: 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). --- actionpack/lib/abstract_controller/helpers.rb | 12 ++++++++++-- 1 file 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. -- cgit v1.2.3