diff options
| author | Jack Nagel | 2014-09-14 01:10:20 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-09-14 01:10:20 -0500 |
| commit | a2da10153a24cdc513eb26b82fb48e83f9f5edc6 (patch) | |
| tree | c12af1209154c14988817620203cfcca8a657f77 /Library | |
| parent | a8d49d1181a3cf7153f882e01bb42117a64af210 (diff) | |
| download | homebrew-a2da10153a24cdc513eb26b82fb48e83f9f5edc6.tar.bz2 | |
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.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 60 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 2 |
2 files changed, 25 insertions, 37 deletions
diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index d104b23dd..7afb0db0e 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -79,46 +79,33 @@ class OperationInProgressError < RuntimeError 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 FormulaAlreadyInstalledError < RuntimeError; end -class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError +class FormulaInstallationAlreadyAttemptedError < RuntimeError def initialize(formula) - super formula, "Formula installation already attempted: #{formula}" + super "Formula installation already attempted: #{formula}" end end -class UnsatisfiedRequirements < Homebrew::InstallationError - attr_reader :reqs - - def initialize formula, reqs - @reqs = reqs - message = (reqs.length == 1) \ - ? "An unsatisfied requirement failed this build." \ - : "Unsatisifed requirements failed this build." - super formula, message +class UnsatisfiedRequirements < RuntimeError + def initialize(reqs) + if reqs.length == 1 + super "An unsatisfied requirement failed this build." + else + super "Unsatisified requirements failed this build." + end end end -class FormulaConflictError < Homebrew::InstallationError - attr_reader :conflicts +class FormulaConflictError < RuntimeError + attr_reader :formula, :conflicts def initialize(formula, conflicts) - @conflicts = conflicts @formula = formula - super formula, message + @conflicts = conflicts + super message end def conflict_message(conflict) @@ -144,13 +131,14 @@ class FormulaConflictError < Homebrew::InstallationError end end -class BuildError < Homebrew::InstallationError - attr_reader :env +class BuildError < RuntimeError + attr_reader :formula, :env def initialize(formula, cmd, args, env) + @formula = formula @env = env args = args.map{ |arg| arg.to_s.gsub " ", "\\ " }.join(" ") - super formula, "Failed executing: #{cmd} #{args}" + super "Failed executing: #{cmd} #{args}" end def issues @@ -202,13 +190,13 @@ end # raised by CompilerSelector if the formula fails with all of # the compilers available on the user's system -class CompilerSelectionError < Homebrew::InstallationError - def initialize formula - super formula, <<-EOS.undent - #{formula.name} cannot be built with any available compilers. - To install this formula, you may need to: - brew install gcc - EOS +class CompilerSelectionError < RuntimeError + def initialize(formula) + super <<-EOS.undent + #{formula.name} cannot be built with any available compilers. + To install this formula, you may need to: + brew install gcc + EOS end end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index ebb08773c..07bcaaf4a 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -232,7 +232,7 @@ class FormulaInstaller end end - raise UnsatisfiedRequirements.new(f, fatals) unless fatals.empty? + raise UnsatisfiedRequirements.new(fatals) unless fatals.empty? end def install_requirement_default_formula?(req, build) |
