Exception: Textus::UnknownKey
- Defined in:
- lib/textus/errors.rb
Instance Attribute Summary collapse
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
Attributes inherited from Error
Instance Method Summary collapse
-
#initialize(key, suggestions: []) ⇒ UnknownKey
constructor
A new instance of UnknownKey.
Methods inherited from Error
#details, #exit_code, #hint, #to_envelope
Constructor Details
#initialize(key, suggestions: []) ⇒ UnknownKey
Returns a new instance of UnknownKey.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/textus/errors.rb', line 37 def initialize(key, suggestions: []) @suggestions = Array(suggestions) details = { "key" => key } details["suggestions"] = @suggestions unless @suggestions.empty? msg = "key '#{key}' does not resolve" msg += "; did you mean: #{@suggestions.join(", ")}" unless @suggestions.empty? hint = if @suggestions.empty? "run 'textus list --output=json' to see all keys" else "did you mean: #{@suggestions.join(", ")}" end super("unknown_key", msg, details: details, hint: hint) end |
Instance Attribute Details
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
35 36 37 |
# File 'lib/textus/errors.rb', line 35 def suggestions @suggestions end |