Exception: Yay::UnexpectedTokenError
- Defined in:
- lib/yay/errors.rb
Overview
raised when an unexpected token was found by the parser. in otherwords, the rules of the syntax have been broken somehow and the user hasn’t written a valid command
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Error
Instance Method Summary collapse
-
#extra_message ⇒ Object
add extra feedback for some tokens.
-
#initialize(type, value, position) ⇒ UnexpectedTokenError
constructor
A new instance of UnexpectedTokenError.
- #printable_message ⇒ Object
Methods inherited from Error
Constructor Details
#initialize(type, value, position) ⇒ UnexpectedTokenError
Returns a new instance of UnexpectedTokenError.
164 165 166 167 168 |
# File 'lib/yay/errors.rb', line 164 def initialize type, value, position @type = type @value = value @position = position end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
161 162 163 |
# File 'lib/yay/errors.rb', line 161 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
162 163 164 |
# File 'lib/yay/errors.rb', line 162 def value @value end |
Instance Method Details
#extra_message ⇒ Object
add extra feedback for some tokens. help the user out!
171 172 173 174 175 |
# File 'lib/yay/errors.rb', line 171 def return "Since #{value} has a special meaning, try enclosing it in quotes or a regex when searching for it" if type == "colour" return "Have you finished the line off properly?" if type == "$end" return "" end |
#printable_message ⇒ Object
177 178 179 180 181 |
# File 'lib/yay/errors.rb', line 177 def return "Unexpected text \"#{value}\"#{printable_position}\n#{}" if type == "error" return "Unexpected end of line#{printable_position}\n#{}" if type == "$end" return "Unexpected #{type} \"#{value}\"#{printable_position}\n#{}" end |