Exception: FormulaOrCaskUnavailableError

Inherits:
RuntimeError
  • Object
show all
Extended by:
T::Sig
Defined in:
exceptions.rb

Overview

Raised when neither a formula nor a cask with the given name is available.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ FormulaOrCaskUnavailableError

Returns a new instance of FormulaOrCaskUnavailableError.



88
89
90
91
92
# File 'exceptions.rb', line 88

def initialize(name)
  super()

  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



86
87
88
# File 'exceptions.rb', line 86

def name
  @name
end

Instance Method Details

#did_you_meanString

Returns:



95
96
97
98
99
100
# File 'exceptions.rb', line 95

def did_you_mean
  similar_formula_names = Formula.fuzzy_search(name)
  return "" if similar_formula_names.blank?

  "Did you mean #{similar_formula_names.to_sentence two_words_connector: " or ", last_word_connector: " or "}?"
end

#to_sString

Returns:



103
104
105
# File 'exceptions.rb', line 103

def to_s
  "No available formula or cask with the name \"#{name}\". #{did_you_mean}".strip
end