named_args: raise rescued error if both formula/cask are unreadable
This commit is contained in:
parent
db6f65ddc0
commit
89930157b5
@ -78,7 +78,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_formula_or_cask(name, only: nil, method: nil)
|
def load_formula_or_cask(name, only: nil, method: nil)
|
||||||
unreadable_errors = []
|
unreadable_error = nil
|
||||||
|
|
||||||
if only != :cask
|
if only != :cask
|
||||||
begin
|
begin
|
||||||
@ -102,7 +102,7 @@ module Homebrew
|
|||||||
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
||||||
# Need to rescue before `FormulaUnavailableError` (superclass of this)
|
# Need to rescue before `FormulaUnavailableError` (superclass of this)
|
||||||
# The formula was found, but there's a problem with its implementation
|
# The formula was found, but there's a problem with its implementation
|
||||||
unreadable_errors << e
|
unreadable_error ||= e
|
||||||
rescue NoSuchKegError, FormulaUnavailableError => e
|
rescue NoSuchKegError, FormulaUnavailableError => e
|
||||||
raise e if only == :formula
|
raise e if only == :formula
|
||||||
end
|
end
|
||||||
@ -114,13 +114,13 @@ module Homebrew
|
|||||||
rescue Cask::CaskUnreadableError => e
|
rescue Cask::CaskUnreadableError => e
|
||||||
# Need to rescue before `CaskUnavailableError` (superclass of this)
|
# Need to rescue before `CaskUnavailableError` (superclass of this)
|
||||||
# The cask was found, but there's a problem with its implementation
|
# The cask was found, but there's a problem with its implementation
|
||||||
unreadable_errors << e
|
unreadable_error ||= e
|
||||||
rescue Cask::CaskUnavailableError => e
|
rescue Cask::CaskUnavailableError => e
|
||||||
raise e if only == :cask
|
raise e if only == :cask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
raise unreadable_errors.first if unreadable_errors.count == 1
|
raise unreadable_error if unreadable_error.present?
|
||||||
|
|
||||||
raise FormulaOrCaskUnavailableError, name
|
raise FormulaOrCaskUnavailableError, name
|
||||||
end
|
end
|
||||||
|
|||||||
@ -99,7 +99,7 @@ describe Homebrew::CLI::NamedArgs do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error" do
|
it "raises an error" do
|
||||||
expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaOrCaskUnavailableError)
|
expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaUnreadableError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if loading formula only" do
|
it "raises an error if loading formula only" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user