Refactor output_unsupported_error.

This commit is contained in:
Markus Reiter 2020-07-26 11:53:05 +02:00
parent db467497ca
commit ca18a72673
3 changed files with 14 additions and 13 deletions

View File

@ -35,13 +35,6 @@ rescue MissingEnvironmentVariables => e
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
end
def output_unsupported_error
$stderr.puts <<~EOS
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC.
EOS
end
begin
trap("INT", std_trap) # restore default CTRL-C handler
@ -150,7 +143,12 @@ rescue BuildError => e
Utils::Analytics.report_build_error(e)
e.dump
output_unsupported_error if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
if e.formula.head? || e.formula.deprecated? || e.formula.disabled?
$stderr.puts <<~EOS
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC.
EOS
end
exit 1
rescue RuntimeError, SystemCallError => e
@ -159,8 +157,6 @@ rescue RuntimeError, SystemCallError => e
onoe e
$stderr.puts e.backtrace if Homebrew.args.debug?
output_unsupported_error if Homebrew.args.HEAD?
exit 1
rescue MethodDeprecatedError => e
onoe e

View File

@ -159,6 +159,11 @@ class ExternalPatch
end
end
end
rescue ErrorDuringExecution => e
raise unless (f = resource.owner&.owner)
cmd, *args = e.cmd
raise BuildError.new(f, cmd, args, ENV.to_hash)
end
def inspect

View File

@ -149,7 +149,7 @@ describe "patching" do
end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution)
}.to raise_error(BuildError)
end
specify "single_patch_dsl_with_incorrect_strip_with_apply" do
@ -163,7 +163,7 @@ describe "patching" do
end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution)
}.to raise_error(BuildError)
end
specify "patch_p0_dsl" do
@ -219,7 +219,7 @@ describe "patching" do
end
f.brew { |formula, _staging| formula.patch }
}.to raise_error(ErrorDuringExecution)
}.to raise_error(BuildError)
end
end