aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/utils.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 928f25fc9..aaf9d8ba5 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -125,9 +125,18 @@ def odeprecated(method, replacement = nil, options = {})
"There is no replacement."
end
- # Show the first location that's not in compat.
- backtrace = options[:caller] || caller
- caller_message = backtrace[1]
+ # Try to show the most relevant location in message, i.e. (if applicable):
+ # - Location in a formula.
+ # - Location outside of 'compat/'.
+ # - Location of caller of deprecated method (if all else fails).
+ backtrace = options.fetch(:caller, caller)
+ caller_message = backtrace.detect do |line|
+ line.start_with?("#{HOMEBREW_LIBRARY}/Taps/")
+ end
+ caller_message ||= backtrace.detect do |line|
+ !line.start_with?("#{HOMEBREW_LIBRARY_PATH}/compat/")
+ end
+ caller_message ||= backtrace[1]
message = <<-EOS.undent
Calling #{method} is #{verb}!
@@ -136,7 +145,7 @@ def odeprecated(method, replacement = nil, options = {})
EOS
if ARGV.homebrew_developer? || options[:die]
- raise FormulaMethodDeprecatedError.new message
+ raise FormulaMethodDeprecatedError, message
else
opoo "#{message}\n"
end