mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
- add `run!` method which raises if command does not succeed - use `run!` when the command we are running must succeed for things to move forward. this should help produce clearer error messages in failure scenarios. - move caveats earlier in the install process so reports can be made about potential failures - remove the destination tree on cask install failure, so the cask will not be considered installed
64 lines
1 KiB
Ruby
64 lines
1 KiB
Ruby
class CaskError < RuntimeError; end
|
|
|
|
class CaskNotInstalledError < CaskError
|
|
attr_reader :cask
|
|
def initialize cask
|
|
@cask = cask
|
|
end
|
|
|
|
def to_s
|
|
"#{cask} is not installed"
|
|
end
|
|
end
|
|
|
|
class CaskUnavailableError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"No available cask for #{name}"
|
|
end
|
|
end
|
|
|
|
class CaskAlreadyCreatedError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"Cask for #{name} already exists. Use `brew cask edit #{name}` to see it."
|
|
end
|
|
end
|
|
|
|
class CaskAlreadyInstalledError < CaskError
|
|
attr_reader :name
|
|
def initialize name
|
|
@name = name
|
|
end
|
|
|
|
def to_s
|
|
"Cask for #{name} is already installed. Use `--force` to install anyways."
|
|
end
|
|
end
|
|
|
|
class CaskCommandFailedError < CaskError
|
|
def initialize cmd, output
|
|
@cmd = cmd
|
|
@output = output
|
|
end
|
|
|
|
def to_s;
|
|
<<-EOS.undent
|
|
Command failed to execute!
|
|
|
|
==> Failed command:
|
|
#{@cmd}
|
|
|
|
==> Output of failed command:
|
|
#{@output}
|
|
EOS
|
|
end
|
|
end
|