Improve rescue nesting.

This commit is contained in:
Mike McQuaid 2016-09-17 17:01:04 +01:00
parent 69e4ad9809
commit 1bdbb0f462
4 changed files with 20 additions and 20 deletions

View File

@ -516,10 +516,10 @@ module Homebrew
# Our gettext formula will be caught by check_linked_keg_only_brews # Our gettext formula will be caught by check_linked_keg_only_brews
gettext = begin gettext = begin
Formulary.factory("gettext") Formulary.factory("gettext")
rescue rescue
nil nil
end end
homebrew_owned = @found.all? do |path| homebrew_owned = @found.all? do |path|
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext" Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
end end
@ -537,10 +537,10 @@ module Homebrew
return if @found.empty? return if @found.empty?
libiconv = begin libiconv = begin
Formulary.factory("libiconv") Formulary.factory("libiconv")
rescue rescue
nil nil
end end
if libiconv && libiconv.linked_keg.directory? if libiconv && libiconv.linked_keg.directory?
unless libiconv.keg_only? unless libiconv.keg_only?
<<-EOS.undent <<-EOS.undent

View File

@ -269,10 +269,10 @@ class AbstractFileDownloadStrategy < AbstractDownloadStrategy
case entries.length case entries.length
when 0 then raise "Empty archive" when 0 then raise "Empty archive"
when 1 then begin when 1 then begin
Dir.chdir entries.first Dir.chdir entries.first
rescue rescue
nil nil
end end
end end
end end

View File

@ -56,10 +56,10 @@ require "compat" unless ARGV.include?("--no-compat") || ENV["HOMEBREW_NO_COMPAT"
ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map do |p| ORIGINAL_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map do |p|
begin begin
Pathname.new(p).expand_path Pathname.new(p).expand_path
rescue rescue
nil nil
end end
end.compact.freeze end.compact.freeze
# TODO: remove this as soon as it's removed from commands.rb. # TODO: remove this as soon as it's removed from commands.rb.

View File

@ -339,10 +339,10 @@ class BottleSpecification
os_versions = collector.keys os_versions = collector.keys
os_versions.map! do |osx| os_versions.map! do |osx|
begin begin
MacOS::Version.from_symbol osx MacOS::Version.from_symbol osx
rescue rescue
nil nil
end end
end.compact! end.compact!
os_versions.sort.reverse_each do |os_version| os_versions.sort.reverse_each do |os_version|
osx = os_version.to_sym osx = os_version.to_sym