Module: Ignorable Private

Includes:
Kernel
Defined in:
ignorable.rb,
ignorable.rbi

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.

Defined Under Namespace

Modules: ExceptionMixin

Constant Summary

Constants included from Kernel

Kernel::IGNORE_INTERRUPTS_MUTEX

Class Method Summary collapse

Methods included from Kernel

#disk_usage_readable, #ensure_executable!, #ensure_formula_installed!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #number_readable, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #paths, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #quiet_system, #redact_secrets, #redirect_stdout, #require?, #safe_system, #tap_and_name_comparison, #truncate_text_to_approximate_size, #which, #which_all, #which_editor, #with_custom_locale, #with_env, #with_homebrew_path

Class Method Details

.hook_raiseObject

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.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'ignorable.rb', line 21

def self.hook_raise
  Object.class_eval do
    alias_method :original_raise, :raise

    def raise(*)
      callcc do |continuation|
        super
      rescue Exception => e # rubocop:disable Lint/RescueException
        unless e.is_a?(ScriptError)
          e.extend(ExceptionMixin)
          T.cast(e, ExceptionMixin).continuation = continuation
        end
        super(e)
      end
    end

    alias_method :fail, :raise
  end

  return unless block_given?

  yield
  unhook_raise
end

.raiseObject

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 is a workaround to enable raise to be aliased



7
# File 'ignorable.rbi', line 7

def self.raise(*); end

.unhook_raiseObject

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.



46
47
48
49
50
51
52
# File 'ignorable.rb', line 46

def self.unhook_raise
  Object.class_eval do
    alias_method :raise, :original_raise
    alias_method :fail, :original_raise
    undef :original_raise
  end
end