Module: Debrew Private

Extended by:
Attrable, Mutex_m
Defined in:
debrew.rb,
sorbet/rbi/parlour.rbi

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

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Attrable

attr_predicate, attr_rw

Class Attribute Details

.debugged_exceptionsObject (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.



78
79
80
# File 'debrew.rb', line 78

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.

Returns:

  • (Boolean)


31
# File 'sorbet/rbi/parlour.rbi', line 31

def self.active?; end

.debrewObject

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.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'debrew.rb', line 81

def self.debrew
  @active = true
  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
    @active = false
  end
end

.debug(exception) ⇒ Object

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.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'debrew.rb', line 97

def self.debug(exception)
  raise(exception) if !active? || !debugged_exceptions.add?(exception) || !mu_try_lock

  begin
    puts exception.backtrace.first
    puts Formatter.error(exception, label: exception.class.name)

    loop do
      Menu.choose do |menu|
        menu.prompt = "Choose an action: "

        menu.choice(:raise) { raise(exception) }
        menu.choice(:ignore) { return :ignore } if exception.is_a?(Ignorable::ExceptionMixin)
        menu.choice(:backtrace) { puts exception.backtrace }

        if exception.is_a?(Ignorable::ExceptionMixin)
          menu.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)
                mu_synchronize do
                  require "debrew/irb"
                  IRB.start_within(binding)
                end
              end
            }

            return :ignore
          end
        end

        menu.choice(:shell) do
          puts "When you exit this shell, you will return to the menu."
          interactive_shell
        end
      end
    end
  ensure
    mu_unlock
  end
end