Skip to content

Commit 734d97d

Browse files
committed
Deprecate MissingSourceFile in favor of LoadError.
`MissingSourceFile` was just an alias to `LoadError` and was not being raised inside the framework.
1 parent 48deeab commit 734d97d

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

activesupport/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
* Deprecate `MissingSourceFile` in favor of `LoadError`.
2+
3+
`MissingSourceFile` was just an alias to `LoadError` and was not being
4+
raised inside the framework.
5+
6+
*Rafael Mendonça França*
7+
18
* Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
29
Now it acts closer to Ruby's rescue.
310

activesupport/lib/active_support/core_ext/load_error.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'active_support/deprecation/proxy_wrappers'
2+
13
class LoadError
24
REGEXPS = [
35
/^no such file to load -- (.+)$/i,
@@ -25,4 +27,4 @@ def is_missing?(location)
2527
end
2628
end
2729

28-
MissingSourceFile = LoadError
30+
MissingSourceFile = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('MissingSourceFile', 'LoadError')

activesupport/test/core_ext/load_error_test.rb

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
require 'abstract_unit'
22
require 'active_support/core_ext/load_error'
33

4+
5+
class TestMissingSourceFile < ActiveSupport::TestCase
6+
def test_it_is_deprecated
7+
assert_deprecated do
8+
MissingSourceFile.new
9+
end
10+
end
11+
end
12+
413
class TestLoadError < ActiveSupport::TestCase
514
def test_with_require
615
assert_raise(LoadError) { require 'no_this_file_don\'t_exist' }

guides/source/active_support_core_extensions.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3873,7 +3873,7 @@ def default_helper_module!
38733873
module_name = name.sub(/Controller$/, '')
38743874
module_path = module_name.underscore
38753875
helper module_path
3876-
rescue MissingSourceFile => e
3876+
rescue LoadError => e
38773877
raise e unless e.is_missing? "helpers/#{module_path}_helper"
38783878
rescue NameError => e
38793879
raise e unless e.missing_name? "#{module_name}Helper"
@@ -3885,7 +3885,7 @@ NOTE: Defined in `active_support/core_ext/name_error.rb`.
38853885
Extensions to `LoadError`
38863886
-------------------------
38873887

3888-
Active Support adds `is_missing?` to `LoadError`, and also assigns that class to the constant `MissingSourceFile` for backwards compatibility.
3888+
Active Support adds `is_missing?` to `LoadError`.
38893889

38903890
Given a path name `is_missing?` tests whether the exception was raised due to that particular file (except perhaps for the ".rb" extension).
38913891

@@ -3896,7 +3896,7 @@ def default_helper_module!
38963896
module_name = name.sub(/Controller$/, '')
38973897
module_path = module_name.underscore
38983898
helper module_path
3899-
rescue MissingSourceFile => e
3899+
rescue LoadError => e
39003900
raise e unless e.is_missing? "helpers/#{module_path}_helper"
39013901
rescue NameError => e
39023902
raise e unless e.missing_name? "#{module_name}Helper"

0 commit comments

Comments
 (0)