From a9556651022a92ae8134b1efbfa67831d5eb2e5e Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Mon, 29 Dec 2014 15:23:01 -0500 Subject: [PATCH] Preserve backtrace from original exception --- Library/Homebrew/extend/ENV/super.rb | 2 +- Library/Homebrew/formulary.rb | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index cb3c12b33b..a23fd7d4ea 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -119,7 +119,7 @@ module Superenv when "gcc-4.2" begin apple_gcc42 = Formulary.factory('apple-gcc42') - rescue Exception # in --debug, catch bare exceptions too + rescue FormulaUnavailableError end paths << apple_gcc42.opt_bin.to_s if apple_gcc42 when GNU_GCC_REGEXP diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 65a7906396..2af67644f0 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -55,8 +55,8 @@ class Formulary def klass begin have_klass = Formulary.formula_class_defined? class_name - rescue NameError - raise FormulaUnavailableError.new(name) + rescue NameError => e + raise FormulaUnavailableError, name, e.backtrace end load_file unless have_klass @@ -78,9 +78,8 @@ class Formulary # This is a programming error in an existing formula, and should not # have a "no such formula" message. raise - rescue LoadError, NameError - raise if ARGV.debug? # let's see the REAL error - raise FormulaUnavailableError.new(name) + rescue LoadError, NameError => e + raise FormulaUnavailableError, name, e.backtrace end end end @@ -174,8 +173,8 @@ class Formulary def get_formula(spec) super - rescue FormulaUnavailableError - raise TapFormulaUnavailableError.new(tapped_name) + rescue FormulaUnavailableError => e + raise TapFormulaUnavailableError, tapped_name, e.backtrace end end