diff options
Diffstat (limited to 'Library/Homebrew/exceptions.rb')
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 60 |
1 files changed, 24 insertions, 36 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 |
