Use odie instead of bare exception
The reason that odie works well here is that it doesn't print a stacktrace or get caught and print the help page.
This commit is contained in:
parent
d291117468
commit
d8c2e311ab
@ -15,9 +15,9 @@ module Homebrew
|
||||
return unless @args.respond_to?(:cask?)
|
||||
return unless @args.cask?
|
||||
|
||||
# NOTE: We don't raise a UsageError here because
|
||||
# we don't want to print the help page.
|
||||
raise "Invalid usage: Casks are not supported on Linux"
|
||||
# NOTE: We don't raise an error here because we don't want
|
||||
# to print the help page or a stack trace.
|
||||
odie "Invalid `--cask` usage: Casks do not work on Linux"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -573,7 +573,9 @@ describe Homebrew::CLI::Parser do
|
||||
|
||||
it "throws an error when defined" do
|
||||
expect { parser.parse(["--cask"]) }
|
||||
.to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux"
|
||||
.to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr
|
||||
.and not_to_output.to_stdout
|
||||
.and raise_exception SystemExit
|
||||
end
|
||||
end
|
||||
|
||||
@ -588,12 +590,16 @@ describe Homebrew::CLI::Parser do
|
||||
|
||||
it "throws an error when --cask defined" do
|
||||
expect { parser.parse(["--cask"]) }
|
||||
.to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux"
|
||||
.to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr
|
||||
.and not_to_output.to_stdout
|
||||
.and raise_exception SystemExit
|
||||
end
|
||||
|
||||
it "throws an error when both defined" do
|
||||
expect { parser.parse(["--cask", "--formula"]) }
|
||||
.to raise_error RuntimeError, "Invalid usage: Casks are not supported on Linux"
|
||||
.to output("Error: Invalid `--cask` usage: Casks do not work on Linux\n").to_stderr
|
||||
.and not_to_output.to_stdout
|
||||
.and raise_exception SystemExit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user