Module: Utils::Backtrace Private
- Defined in:
- utils/backtrace.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
-
.clean(error) ⇒ Array<String>?
private
Cleans
sorbet-runtime
gem paths from the backtrace unless... - .print_backtrace_message ⇒ void private
- .sorbet_runtime_path ⇒ String private
- .tap_error_url(error) ⇒ String? private
Class Method Details
.clean(error) ⇒ Array<String>?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Cleans sorbet-runtime
gem paths from the backtrace unless...
verbose
is set- first backtrace line starts with
sorbet-runtime
- This implies that the error is related to Sorbet.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'utils/backtrace.rb', line 13 def self.clean(error) backtrace = error.backtrace return backtrace if Context.current.verbose? return backtrace if backtrace.blank? return backtrace if backtrace.fetch(0).start_with?(sorbet_runtime_path) old_backtrace_length = backtrace.length backtrace.reject { |line| line.start_with?(sorbet_runtime_path) } .tap { |new_backtrace| if old_backtrace_length > new_backtrace.length } end |
.print_backtrace_message ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
31 32 33 34 35 36 37 38 |
# File 'utils/backtrace.rb', line 31 def self. return if @print_backtrace_message opoo "Removed Sorbet lines from backtrace!" puts "Rerun with `--verbose` to see the original backtrace" unless Homebrew::EnvConfig.no_env_hints? @print_backtrace_message = true end |
.sorbet_runtime_path ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
26 27 28 |
# File 'utils/backtrace.rb', line 26 def self.sorbet_runtime_path @sorbet_runtime_path ||= T.let("#{Gem.paths.home}/gems/sorbet-runtime", T.nilable(String)) end |
.tap_error_url(error) ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'utils/backtrace.rb', line 41 def self.tap_error_url(error) backtrace = error.backtrace return if backtrace.blank? backtrace.each do |line| if (tap = line.match(%r{/Library/Taps/([^/]+/[^/]+)/})) return "https://github.com/#{tap[1]}/issues/new" end end nil end |