Exception: Ergane::CommandNotFound

Inherits:
Error show all
Defined in:
lib/ergane/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, available: []) ⇒ CommandNotFound

Returns a new instance of CommandNotFound.



9
10
11
12
13
14
15
16
17
# File 'lib/ergane/errors.rb', line 9

def initialize(token, available: [])
  @token = token
  @available = available
  suggestion = find_suggestion
  msg = "Unknown command: '#{token}'"
  msg += ". Did you mean '#{suggestion}'?" if suggestion
  msg += "\nAvailable commands: #{available.join(', ')}" if available.any?
  super(msg)
end

Instance Attribute Details

#availableObject (readonly)

Returns the value of attribute available.



7
8
9
# File 'lib/ergane/errors.rb', line 7

def available
  @available
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/ergane/errors.rb', line 7

def token
  @token
end