Remove InstallationError superclass

None of these subclasses share any behavior other than what is inherited
from RuntimeError, so we can just get rid of the superclass.
This commit is contained in:
Jack Nagel 2014-09-14 01:10:20 -05:00
parent 909c2bd59e
commit 081036c81c
2 changed files with 25 additions and 37 deletions

View File

@ -79,46 +79,33 @@ class OperationInProgressError < RuntimeError
end end
end end
module Homebrew
class InstallationError < RuntimeError
attr_reader :formula
def initialize(formula, message)
super message
@formula = formula
end
end
end
class CannotInstallFormulaError < RuntimeError; end class CannotInstallFormulaError < RuntimeError; end
class FormulaAlreadyInstalledError < RuntimeError; end class FormulaAlreadyInstalledError < RuntimeError; end
class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError class FormulaInstallationAlreadyAttemptedError < RuntimeError
def initialize(formula) def initialize(formula)
super formula, "Formula installation already attempted: #{formula}" super "Formula installation already attempted: #{formula}"
end end
end end
class UnsatisfiedRequirements < Homebrew::InstallationError class UnsatisfiedRequirements < RuntimeError
attr_reader :reqs def initialize(reqs)
if reqs.length == 1
def initialize formula, reqs super "An unsatisfied requirement failed this build."
@reqs = reqs else
message = (reqs.length == 1) \ super "Unsatisified requirements failed this build."
? "An unsatisfied requirement failed this build." \ end
: "Unsatisifed requirements failed this build."
super formula, message
end end
end end
class FormulaConflictError < Homebrew::InstallationError class FormulaConflictError < RuntimeError
attr_reader :conflicts attr_reader :formula, :conflicts
def initialize(formula, conflicts) def initialize(formula, conflicts)
@conflicts = conflicts
@formula = formula @formula = formula
super formula, message @conflicts = conflicts
super message
end end
def conflict_message(conflict) def conflict_message(conflict)
@ -144,13 +131,14 @@ class FormulaConflictError < Homebrew::InstallationError
end end
end end
class BuildError < Homebrew::InstallationError class BuildError < RuntimeError
attr_reader :env attr_reader :formula, :env
def initialize(formula, cmd, args, env) def initialize(formula, cmd, args, env)
@formula = formula
@env = env @env = env
args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ") args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ")
super formula, "Failed executing: #{cmd} #{args}" super "Failed executing: #{cmd} #{args}"
end end
def issues def issues
@ -202,13 +190,13 @@ end
# raised by CompilerSelector if the formula fails with all of # raised by CompilerSelector if the formula fails with all of
# the compilers available on the user's system # the compilers available on the user's system
class CompilerSelectionError < Homebrew::InstallationError class CompilerSelectionError < RuntimeError
def initialize formula def initialize(formula)
super formula, <<-EOS.undent super <<-EOS.undent
#{formula.name} cannot be built with any available compilers. #{formula.name} cannot be built with any available compilers.
To install this formula, you may need to: To install this formula, you may need to:
brew install gcc brew install gcc
EOS EOS
end end
end end

View File

@ -232,7 +232,7 @@ class FormulaInstaller
end end
end end
raise UnsatisfiedRequirements.new(f, fatals) unless fatals.empty? raise UnsatisfiedRequirements.new(fatals) unless fatals.empty?
end end
def install_requirement_default_formula?(req, build) def install_requirement_default_formula?(req, build)