Permalink
Browse files

Deprecate `MissingSourceFile` in favor of `LoadError`.

`MissingSourceFile` was just an alias to `LoadError` and was not
being raised inside the framework.
  • Loading branch information...
rafaelfranca committed Jan 2, 2015
1 parent 48deeab commit 734d97d292b4f04c13f03625e07f2888e88b0649
@@ -1,3 +1,10 @@
* Deprecate `MissingSourceFile` in favor of `LoadError`.
`MissingSourceFile` was just an alias to `LoadError` and was not being
raised inside the framework.
*Rafael Mendonça França*
* Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
Now it acts closer to Ruby's rescue.
@@ -1,3 +1,5 @@
require 'active_support/deprecation/proxy_wrappers'
class LoadError
REGEXPS = [
/^no such file to load -- (.+)$/i,
@@ -25,4 +27,4 @@ def is_missing?(location)
end
end
MissingSourceFile = LoadError
MissingSourceFile = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('MissingSourceFile', 'LoadError')
@@ -1,6 +1,15 @@
require 'abstract_unit'
require 'active_support/core_ext/load_error'
class TestMissingSourceFile < ActiveSupport::TestCase
def test_it_is_deprecated
assert_deprecated do
MissingSourceFile.new
end
end
end
class TestLoadError < ActiveSupport::TestCase
def test_with_require
assert_raise(LoadError) { require 'no_this_file_don\'t_exist' }
@@ -3873,7 +3873,7 @@ def default_helper_module!
module_name = name.sub(/Controller$/, '')
module_path = module_name.underscore
helper module_path
rescue MissingSourceFile => e
rescue LoadError => e
raise e unless e.is_missing? "helpers/#{module_path}_helper"
rescue NameError => e
raise e unless e.missing_name? "#{module_name}Helper"
@@ -3885,7 +3885,7 @@ NOTE: Defined in `active_support/core_ext/name_error.rb`.
Extensions to `LoadError`
-------------------------
Active Support adds `is_missing?` to `LoadError`, and also assigns that class to the constant `MissingSourceFile` for backwards compatibility.
Active Support adds `is_missing?` to `LoadError`.
Given a path name `is_missing?` tests whether the exception was raised due to that particular file (except perhaps for the ".rb" extension).
@@ -3896,7 +3896,7 @@ def default_helper_module!
module_name = name.sub(/Controller$/, '')
module_path = module_name.underscore
helper module_path
rescue MissingSourceFile => e
rescue LoadError => e
raise e unless e.is_missing? "helpers/#{module_path}_helper"
rescue NameError => e
raise e unless e.missing_name? "#{module_name}Helper"

0 comments on commit 734d97d

Please sign in to comment.