Module: Debrew Private
- Defined in:
- debrew.rb
Overview
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.
Helper module for debugging formulae.
Defined Under Namespace
Modules: Formula Classes: Menu, self
Class Attribute Summary collapse
- .debugged_exceptions ⇒ Set<Exception> readonly private
Class Method Summary collapse
- .active? ⇒ Boolean private
- .debrew(&_block) ⇒ T.type_parameter(:U) private
- .debug(exception) ⇒ Symbol private
Class Attribute Details
.debugged_exceptions ⇒ Set<Exception> (readonly)
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.
88 89 90 |
# File 'debrew.rb', line 88 def debugged_exceptions @debugged_exceptions end |
Class Method Details
.active? ⇒ Boolean
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.
91 |
# File 'debrew.rb', line 91 def active? = !@mutex.nil? |
.debrew(&_block) ⇒ T.type_parameter(:U)
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.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'debrew.rb', line 99 def self.debrew(&_block) @mutex = Mutex.new Ignorable.hook_raise begin yield rescue SystemExit raise rescue Ignorable::ExceptionMixin => e e.ignore if debug(e) == :ignore # execution jumps back to where the exception was thrown ensure Ignorable.unhook_raise @mutex = nil end end |
.debug(exception) ⇒ Symbol
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.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'debrew.rb', line 116 def self.debug(exception) raise(exception) if !active? || !debugged_exceptions.add?(exception) || !@mutex&.try_lock begin puts exception.backtrace&.first puts Formatter.error(exception, label: exception.class.name) loop do Menu.choose do || .prompt = "Choose an action: " .choice(:raise) { raise(exception) } .choice(:ignore) { return :ignore } if exception.is_a?(Ignorable::ExceptionMixin) .choice(:backtrace) { puts exception.backtrace } if exception.is_a?(Ignorable::ExceptionMixin) .choice(:irb) do puts "When you exit this IRB session, execution will continue." set_trace_func proc { |event, _, _, id, binding, klass| if klass == Object && id == :raise && event == "return" set_trace_func(nil) @mutex.synchronize do require "debrew/irb" IRB.start_within(binding) end end } return :ignore end end .choice(:shell) do puts "When you exit this shell, you will return to the menu." interactive_shell end end end ensure @mutex.unlock end end |