From 262a503b6f0080f413a4dca72384e00b6a83f602 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 22 Aug 2014 22:36:58 -0500 Subject: [PATCH] Decouple IncompatibleCxxStdlibs from its superclass This exception is never used outside of the CxxStdlib class, so we don't need the Homebrew::InstallationError superclass. --- Library/Homebrew/cxxstdlib.rb | 13 +++++++++++-- Library/Homebrew/exceptions.rb | 9 --------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb index 859c1aabba..7c3beafc84 100644 --- a/Library/Homebrew/cxxstdlib.rb +++ b/Library/Homebrew/cxxstdlib.rb @@ -3,6 +3,15 @@ require "compilers" class CxxStdlib include CompilerConstants + class CompatibilityError < StandardError + def initialize(formula, dep, stdlib) + super <<-EOS.undent + #{formula.name} dependency #{dep.name} was built with a different C++ standard + library (#{stdlib.type_string} from #{stdlib.compiler}). This may cause problems at runtime. + EOS + end + end + def self.create(type, compiler) if type && ![:libstdcxx, :libcxx].include?(type) raise ArgumentError, "Invalid C++ stdlib type: #{type}" @@ -18,7 +27,7 @@ class CxxStdlib begin stdlib.check_dependencies(formula, deps) - rescue IncompatibleCxxStdlibs => e + rescue CompatibilityError => e opoo e.message end end @@ -51,7 +60,7 @@ class CxxStdlib dep_stdlib = Tab.for_formula(dep.to_formula).cxxstdlib if !compatible_with? dep_stdlib - raise IncompatibleCxxStdlibs.new(formula, dep, dep_stdlib, self) + raise CompatibilityError.new(formula, dep, dep_stdlib) end end end diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index d0d83bc893..743f63b0f1 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -112,15 +112,6 @@ class UnsatisfiedRequirements < Homebrew::InstallationError end end -class IncompatibleCxxStdlibs < Homebrew::InstallationError - def initialize(f, dep, wrong, right) - super f, <<-EOS.undent - #{f} dependency #{dep} was built with a different C++ standard - library (#{wrong.type_string} from #{wrong.compiler}). This could cause problems at runtime. - EOS - end -end - class FormulaConflictError < Homebrew::InstallationError attr_reader :f, :conflicts