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
#code, #details, #exit_code, #hint
Instance Method Summary collapse
-
#initialize(key, suggestions: []) ⇒ UnknownKey
constructor
A new instance of UnknownKey.
Methods inherited from Error
Constructor Details
#initialize(key, suggestions: []) ⇒ UnknownKey
Returns a new instance of UnknownKey.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/textus/errors.rb', line 29 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 --format=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.
27 28 29 |
# File 'lib/textus/errors.rb', line 27 def suggestions @suggestions end |