Skip to content

Commit

Permalink
[rubygems/rubygems] Replace StandardError with Exception
Browse files Browse the repository at this point in the history
We think it's unlikely that `rubygems/defaults/operating_system` could be shipped with a SyntaxError so StandardError could be better choice to prevent "false positives" errors.

rubygems/rubygems@1f73e784dd
  • Loading branch information
daniel-niknam authored and hsbt committed Aug 31, 2021
1 parent 34e073c commit 717ad64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Expand Up @@ -1332,7 +1332,7 @@ def default_gem_load_paths
require 'rubygems/defaults/operating_system'
rescue LoadError
# Ignored
rescue Exception => e
rescue StandardError => e
msg = "#{e.message}\n" \
"Loading the rubygems/defaults/operating_system.rb file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_rubygems.rb
Expand Up @@ -10,12 +10,12 @@ def test_operating_system_other_exceptions
pend "does not apply to truffleruby" if RUBY_ENGINE == 'truffleruby'

path = util_install_operating_system_rb <<-RUBY
intentional synt'ax error
intentionally_not_implemented_method
RUBY

output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
assert !$?.success?
assert_includes output, "unterminated string meets end of file (SyntaxError)"
assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'"
assert_includes output, "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
Expand Down

0 comments on commit 717ad64

Please sign in to comment.