Skip to content
Browse files

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).
  • Loading branch information...
1 parent f278b06 commit 99c9d18601539c7e7e87f26bb047add1f93072af @tenderlove tenderlove committed Jun 14, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 actionpack/lib/abstract_controller/helpers.rb
View
12 actionpack/lib/abstract_controller/helpers.rb
@@ -135,8 +135,7 @@ def modules_for_helpers(args)
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 @@ def modules_for_helpers(args)
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.

0 comments on commit 99c9d18

Please sign in to comment.
Something went wrong with that request. Please try again.